NoImageDataConversion Property (original) (raw)
Summary
Gets or sets a value indicating whether image data is automatically converted during load.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool NoImageDataConversion { get; set; }
@property (nonatomic, assign) BOOL NoImageDataConversion;
public boolean getNoImageDataConversion()
public void setNoImageDataConversion(boolean value)
public:
property bool NoImageDataConversion {
bool get();
void set ( bool );
}
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. |
Example
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);
image.Access();
/* 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);
image.Release();
/* 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
Marshal.FreeHGlobal(buffer);
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Leadtools.Codecs Assembly
CompactFile(Stream,Stream,int,int,bool,int,int,bool,int,CodecsSavePageMode,bool,bool) Method
CompactFile(Stream,Stream,int,int,bool,long,int,bool,long,CodecsSavePageMode,bool,bool,bool) Method
CompactFile(string,string,int,int,bool,int,int,bool,int,CodecsSavePageMode,bool,bool) Method
CompactFile(string,string,int,int,bool,long,int,bool,long,CodecsSavePageMode,bool,bool,bool) Method