←Select platform

NoImageDataConversion Property

Gets or sets a value indicating whether image data is automatically converted during load.
public bool NoImageDataConversion { get; set; } 
@property (nonatomic, assign) BOOL NoImageDataConversion; 
public boolean getNoImageDataConversion() 
public void setNoImageDataConversion(boolean value) 
property bool NoImageDataConversion { 
   bool get(); 
   void set (    bool ); 
NoImageDataConversion # get and set (CodecsLoadOptions) 

Property Value

Value Description
true To prevent conversion of of image data. This allows you to load floating point images.
false To allow automatic conversion of image data. The default value is false.

LEADTOOLS will sometimes automatically convert some image data during load to ensure proper display. Some of the situations are listed below: 1) Floating point values from some TIFF or GeoTIFF files are automatically scaled and converted to integer. The scale is done to take the minimum value to black and maximum value to white. 2) Data in some JPEG-LS files is automatically converted to ensure proper display. (Without this conversion, some images would look all black).

Applications that need more control over the image data can set NoImageDataConversion to true prevents this automatic conversion. But in this case, the application might need to perform extra steps before the image can be displayed properly.

If you set NoImageDataConversion to true and load a TIFF/GeoTIFF with floating point values, you will obtain a floating point image. This will allow you to perform certain calculations over the floating point data. But LEADTOOLS has minimal support for images with floating point pixels, which is why the floating point values are converted and scaled during load by default.

For support details on the image's floating point pixels, refer to Working With Floating Point Images.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
public void TestLoadFloat() 
   //This example loads floating point values from a GeoTIFF file. It extracts data from the image and examines a few pixel values. 
   using (RasterCodecs codecs = new RasterCodecs()) 
      string srcFile = Path.Combine(LEAD_VARS.ImagesDir, "test_GeoKey.TIF"); 
      codecs.Options.Load.NoImageDataConversion = true; 
      using (RasterImage image = codecs.Load(srcFile, 1)) 
         // RasterImage.Float will be true if the image was loaded with floating point pixels 
         Debug.WriteLine($"RasterImage.Float = {image.Float}"); 
         /* Allocate an unmanaged pointer for getting row data. The buffer size is in bytes, so we need to use image.BytesPerLine or image.Width*4  */ 
         IntPtr buffer = Marshal.AllocHGlobal(image.BytesPerLine); 
         /* get the floating point data for row 186 into an unmanaged pointer. If your image does not have 187 rows, adjust the row number */ 
         image.GetRow(186, buffer, image.BytesPerLine); 
         /* You can't cast to float in C#, so we will need to allocate a managed array of float values and copy the unmanaged data into it */ 
         float[] floatBuf = new float[image.Width]; 
         // Note that copy should use image.Width, not image.BytesPerLine! 
         Marshal.Copy(buffer, floatBuf, 0, image.Width); 
         /* Examine a few pixels from line. If the values are garbage, make sure RasterImage.Float = true. If RasterImage.Float = false, then the source file did not have floating point values */ 
         Debug.WriteLine($"Line 186: [146] = {floatBuf[146]}, [421] = {floatBuf[421]}, [568] = {floatBuf[568]}"); 
         // Free the unmanaged pointer 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 

Target Platforms

Help Version 22.0.2023.5.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.