Occurs during loading of a file for which LEADTOOLS cannot recognize the format.
public event EventHandler<CodecsLoadInformationEventArgs> LoadInformation Public Event LoadInformation As EventHandler(Of CodecsLoadInformationEventArgs) synchronized public void addLoadInformationListener(CodecsLoadInformationListener listener)synchronized public void removeLoadInformationListener(CodecsLoadInformationListener listener)
public:event EventHandler<CodecsLoadInformationEventArgs^>^ LoadInformation
The event handler receives an argument of type CodecsLoadInformationEventArgs containing data related to this event. The following CodecsLoadInformationEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| BitsPerPixel | Gets or sets the bits per pixel of the image data in the file. |
| Format | Gets the image file format. |
| Height | Gets or sets the image height in pixels. |
| LeastSignificantBitFirst | Gets or sets a value specifying whether the image data was saved with least significant bit first or last. |
| MotorolaOrder | Gets or sets a value that determines whether image data is in Motorola byte order. |
| Offset | Gets or sets the position of the first byte of image data. |
| Order | Gets or sets the byte order for the load process. |
| Pad4 | Gets or sets a value indicating whether the image data was saved padded to 4-byte boundary. |
| PhotoInterpolation | Gets or sets the photometric interpolation for the load process. |
| PlanarConfiguration | Gets or sets the planar configuration. |
| Reverse | Gets or sets a value that determines whether each line is reversed (mirrored). |
| Signed | Gets or sets a value that determines whether the image data is signed. |
| Stream | Gets the stream used by the load process. |
| StripSize | Gets or sets the size of the data strip before it is decompressed. |
| ViewPerspective | Gets or sets the view perspective for the load process. |
| WhiteOnBlack | Gets or sets a value that determines if the image is black-on-white or white on black. |
| Width | Gets or sets the image width in pixels. |
| XResolution | Gets or sets the horizontal resolution for rendering the image, specified in dots per inch. |
| YResolution | Gets or sets the vertical resolution for rendering the image, specified in dots per inch. |
The LoadInformation event will occur when LEADTOOLS cannot recognize the image file format during a call to GetInformation or GetInformationAsync. This event can be used for loading raw FAX data (CCITT Group 3 or Group 4), raw run-length-encoded data (4-bit or 8-bit), raw Bitfield compressed data, raw PackBits compressed data or raw uncompressed data.
To load a raw fax file, you must subscribe to this event first. When the toolkit fails to recognize the image file format, it will fire this event. If you know the size of the fax image, then set the values in the CodecsLoadInformationEventArgs.Width and CodecsLoadInformationEventArgs.Height properties of the CodecsLoadInformationEventArgs passed as the event data. To automatically detect the width and height of the fax file, set CodecsLoadInformationEventArgs.Width and CodecsLoadInformationEventArgs.Height to -1.
To load raw uncompressed data, you must subscribe to this event first. When the toolkit fails to recognize the image file format, it will fire this event. Set the CodecsLoadInformationEventArgs.Format property to RasterImageFormat.Raw. Valid values must also be set for the following properties:
If each line of RAW data is padded so that the number of bytes is a multiple of 4 (as is the case with raw Windows BMP data), set CodecsLoadInformationEventArgs.Pad4 to true. Include an orientation in the CodecsLoadInformationEventArgs.ViewPerspective to load with the proper orientation. For example, raw Windows BMP data is stored with a RasterViewPerspective.BottomLeft orientation. If the orientation is unknown, then set it to RasterViewPerspective.BottomLeft. If the raw data is 8 bits per pixel or less, then the image is palettized and a palette must be generated. If this is the case, pass in a valid palette with 1 << bits/pixel (2 ^ BitsPerPixel) number of entries to the CodecsLoadInformationEventArgs.SetPalette method.
Set the correct color order in the CodecsLoadInformationEventArgs.Order property. For example, if the order of the data is BGR, then set this value to RasterByteOrder.Bgr.
For more information, refer to CodecsLoadInformationEventArgs.
This example demonstrates saving and loading raw/headerless image files.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;using LeadtoolsExamples.Common;private struct RawData{public int Width; // Width of imagepublic int Height; // Height of imagepublic int BitsPerPixel; // Bits per pixel of image--if palettized, a gray palette is generatedpublic RasterViewPerspective ViewPerspective; // View perspective of raw data (TopLeft, BottomLeft, etc)public RasterByteOrder Order; // Rgb or Bgrpublic int XResolution; // Horizontal resolution in DPIpublic int YResolution; // Vertical resolution in DPIpublic int Offset; // Offset into file where raw data beginspublic bool Padding; // true if each line of data is padded to four bytespublic bool ReverseBits; // true if the bits of each byte are reversed}private RawData myRawData;private void codecs_LoadInformation(object sender, CodecsLoadInformationEventArgs e){// Set the informatione.Format = RasterImageFormat.Raw;e.Width = myRawData.Width;e.Height = myRawData.Height;e.BitsPerPixel = myRawData.BitsPerPixel;e.XResolution = myRawData.XResolution;e.YResolution = myRawData.YResolution;e.Offset = myRawData.Offset;if (myRawData.Padding)e.Pad4 = true;e.Order = myRawData.Order;if (myRawData.ReverseBits)e.LeastSignificantBitFirst = true;e.ViewPerspective = myRawData.ViewPerspective;// If image is palettized create a grayscale paletteif (e.BitsPerPixel <= 8){int colors = 1 << e.BitsPerPixel;RasterColor[] palette = new RasterColor[colors];for (int i = 0; i < palette.Length; i++){byte val = (byte)((i * 255) / (colors - 1));palette[i] = new RasterColor(val, val, val);}e.SetPalette(palette);}}public void LoadInformationExample(){RasterCodecs codecs = new RasterCodecs();// First, load a JPEG or CMP filestring srcFilename = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");string rawFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.raw");RasterImage image = codecs.Load(srcFilename);// Save this image as RAW data// Set RAW optionscodecs.Options.Raw.Save.Pad4 = true;codecs.Options.Raw.Save.ReverseBits = true;codecs.Options.Save.OptimizedPalette = true;codecs.Save(image, rawFileName, RasterImageFormat.Raw, 0);// Save information about this image so we can use it to load the RAW filemyRawData = new RawData();myRawData.Width = image.Width;myRawData.Height = image.Height;myRawData.BitsPerPixel = image.BitsPerPixel;myRawData.ViewPerspective = image.ViewPerspective;myRawData.Order = image.Order;myRawData.XResolution = image.XResolution;myRawData.YResolution = image.YResolution;myRawData.Offset = 0;myRawData.Padding = true;myRawData.ReverseBits = true;// We dont need the image anymoreimage.Dispose();// Now load this RAW image back// First subscribe to the LoadInformation event so we can set the image informationcodecs.LoadInformation += new EventHandler<CodecsLoadInformationEventArgs>(codecs_LoadInformation);// Load the imageimage = codecs.Load(rawFileName);// Unsubscribe from the eventcodecs.LoadInformation -= new EventHandler<CodecsLoadInformationEventArgs>(codecs_LoadInformation);// save it as bmp for testingcodecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_raw.bmp"), RasterImageFormat.Bmp, 0);// Clean upimage.Dispose();codecs.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.DrawingImports Leadtools.SvgPrivate Structure RawDataPublic Width As Integer ' Width of imagePublic Height As Integer ' Height of imagePublic BitsPerPixel As Integer ' Bits per pixel of image--if palettized, a gray palette is generatedPublic ViewPerspective As RasterViewPerspective ' View perspective of raw data (TopLeft, BottomLeft, etc)Public Order As RasterByteOrder ' Rgb or BgrPublic XResolution As Integer ' Horizontal resolution in DPIPublic YResolution As Integer ' Vertical resolution in DPIPublic Offset As Integer ' Offset into file where raw data beginsPublic Padding As Boolean ' true if each line of data is padded to four bytesPublic ReverseBits As Boolean ' true if the bits of each byte are reversedEnd StructurePrivate myRawData As RawDataPrivate Sub codecs_LoadInformation(ByVal sender As Object, ByVal e As CodecsLoadInformationEventArgs)' Set the informatione.Format = RasterImageFormat.Rawe.Width = myRawData.Widthe.Height = myRawData.Heighte.BitsPerPixel = myRawData.BitsPerPixele.XResolution = myRawData.XResolutione.YResolution = myRawData.YResolutione.Offset = myRawData.OffsetIf myRawData.Padding Thene.Pad4 = TrueEnd Ife.Order = myRawData.OrderIf myRawData.ReverseBits Thene.LeastSignificantBitFirst = TrueEnd Ife.ViewPerspective = myRawData.ViewPerspective' If image is palettized create a grayscale paletteIf e.BitsPerPixel <= 8 ThenDim colors As Integer = 1 << e.BitsPerPixelDim palette As RasterColor() = New RasterColor(colors - 1) {}Dim i As Integer = 0Do While i < palette.LengthDim val As Byte = CByte((i * 255) / (colors - 1))palette(i) = New RasterColor(val, val, val)i += 1Loope.SetPalette(palette)End IfEnd SubPublic Sub LoadInformationExample()Dim codecs As RasterCodecs = New RasterCodecs()' First, load a JPEG or CMP fileDim srcFilename As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")Dim rawFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.raw")Dim image As RasterImage = codecs.Load(srcFilename)' Save this image as RAW data' Set RAW optionscodecs.Options.Raw.Save.Pad4 = Truecodecs.Options.Raw.Save.ReverseBits = Truecodecs.Options.Save.OptimizedPalette = Truecodecs.Save(image, rawFileName, RasterImageFormat.Raw, 0)' Save information about this image so we can use it to load the RAW filemyRawData = New RawData()myRawData.Width = image.WidthmyRawData.Height = image.HeightmyRawData.BitsPerPixel = image.BitsPerPixelmyRawData.ViewPerspective = image.ViewPerspectivemyRawData.Order = image.OrdermyRawData.XResolution = image.XResolutionmyRawData.YResolution = image.YResolutionmyRawData.Offset = 0myRawData.Padding = TruemyRawData.ReverseBits = True' We dont need the image anymoreimage.Dispose()' Now load this RAW image back' First subscribe to the LoadInformation event so we can set the image informationAddHandler codecs.LoadInformation, AddressOf codecs_LoadInformation' Load the imageimage = codecs.Load(rawFileName)' Unsubscribe from the eventRemoveHandler codecs.LoadInformation, AddressOf codecs_LoadInformation' save it as bmp for testingcodecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_raw.bmp"), RasterImageFormat.Bmp, 0)' Clean upimage.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
c#[Silverlight C# Example]using Leadtools;using Leadtools.Codecs;using Leadtools.Examples;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Windows.Media;private struct RawData{public int Width; // Width of imagepublic int Height; // Height of imagepublic int BitsPerPixel; // Bits per pixel of image--if palettized, a gray palette is generatedpublic RasterViewPerspective ViewPerspective; // View perspective of raw data (TopLeft, BottomLeft, etc)public RasterByteOrder Order; // Rgb or Bgrpublic int XResolution; // Horizontal resolution in DPIpublic int YResolution; // Vertical resolution in DPIpublic int Offset; // Offset into file where raw data beginspublic bool Padding; // true if each line of data is padded to four bytespublic bool ReverseBits; // true if the bits of each byte are reversed}private RawData myRawData;private void codecs_LoadInformation(object sender, CodecsLoadInformationEventArgs e){// Set the informatione.Format = RasterImageFormat.Raw;e.Width = myRawData.Width;e.Height = myRawData.Height;e.BitsPerPixel = myRawData.BitsPerPixel;e.XResolution = myRawData.XResolution;e.YResolution = myRawData.YResolution;e.Offset = myRawData.Offset;if (myRawData.Padding)e.Pad4 = true;e.Order = myRawData.Order;if (myRawData.ReverseBits)e.LeastSignificantBitFirst = true;e.ViewPerspective = myRawData.ViewPerspective;// If image is palettized create a grayscale paletteif (e.BitsPerPixel <= 8){int colors = 1 << e.BitsPerPixel;RasterColor[] palette = new RasterColor[colors];for (int i = 0; i < palette.Length; i++){byte val = (byte)((i * 255) / (colors - 1));palette[i] = new RasterColor(val, val, val);}e.SetPalette(palette);}}public void LoadInformationExample(Stream inStreamCmp, Stream outStreamRaw, Stream outStreamBmp){RasterCodecs codecs = new RasterCodecs();// First, load a JPEG or CMP fileRasterImage image = codecs.Load(inStreamCmp);// Save this image as RAW data// Set RAW optionscodecs.Options.Raw.Save.Pad4 = true;codecs.Options.Raw.Save.ReverseBits = true;codecs.Options.Save.OptimizedPalette = true;codecs.Save(image, outStreamRaw, RasterImageFormat.Raw, 0);// Save information about this image so we can use it to load the RAW filemyRawData = new RawData();myRawData.Width = image.Width;myRawData.Height = image.Height;myRawData.BitsPerPixel = image.BitsPerPixel;myRawData.ViewPerspective = image.ViewPerspective;myRawData.Order = image.Order;myRawData.XResolution = image.XResolution;myRawData.YResolution = image.YResolution;myRawData.Offset = 0;myRawData.Padding = true;myRawData.ReverseBits = true;// We dont need the image anymoreimage.Dispose();// Now load this RAW image back// First subscribe to the LoadInformation event so we can set the image informationcodecs.LoadInformation += new EventHandler<CodecsLoadInformationEventArgs>(codecs_LoadInformation);// Load the imageimage = codecs.Load(outStreamRaw);// Unsubscribe from the eventcodecs.LoadInformation -= new EventHandler<CodecsLoadInformationEventArgs>(codecs_LoadInformation);// save it as bmp for testingcodecs.Save(image, outStreamBmp, RasterImageFormat.Bmp, 0);// Clean upimage.Dispose();}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.Windows.MediaPrivate Structure RawDataPublic Width As Integer ' Width of imagePublic Height As Integer ' Height of imagePublic BitsPerPixel As Integer ' Bits per pixel of image--if palettized, a gray palette is generatedPublic ViewPerspective As RasterViewPerspective ' View perspective of raw data (TopLeft, BottomLeft, etc)Public Order As RasterByteOrder ' Rgb or BgrPublic XResolution As Integer ' Horizontal resolution in DPIPublic YResolution As Integer ' Vertical resolution in DPIPublic Offset As Integer ' Offset into file where raw data beginsPublic Padding As Boolean ' true if each line of data is padded to four bytesPublic ReverseBits As Boolean ' true if the bits of each byte are reversedEnd StructurePrivate myRawData As RawDataPrivate Sub codecs_LoadInformation(ByVal sender As Object, ByVal e As CodecsLoadInformationEventArgs)' Set the informatione.Format = RasterImageFormat.Rawe.Width = myRawData.Widthe.Height = myRawData.Heighte.BitsPerPixel = myRawData.BitsPerPixele.XResolution = myRawData.XResolutione.YResolution = myRawData.YResolutione.Offset = myRawData.OffsetIf myRawData.Padding Thene.Pad4 = TrueEnd Ife.Order = myRawData.OrderIf myRawData.ReverseBits Thene.LeastSignificantBitFirst = TrueEnd Ife.ViewPerspective = myRawData.ViewPerspective' If image is palettized create a grayscale paletteIf e.BitsPerPixel <= 8 ThenDim colors As Integer = 1 << e.BitsPerPixelDim palette As RasterColor() = New RasterColor(colors - 1) {}Dim i As Integer = 0Do While i < palette.LengthDim val As Byte = CByte((i * 255) / (colors - 1))palette(i) = New RasterColor(val, val, val)i += 1Loope.SetPalette(palette)End IfEnd SubPublic Sub LoadInformationExample(ByVal inStreamCmp As Stream, ByVal outStreamRaw As Stream, ByVal outStreamBmp As Stream)Dim codecs As RasterCodecs = New RasterCodecs()' First, load a JPEG or CMP fileDim image As RasterImage = codecs.Load(inStreamCmp)' Save this image as RAW data' Set RAW optionscodecs.Options.Raw.Save.Pad4 = Truecodecs.Options.Raw.Save.ReverseBits = Truecodecs.Options.Save.OptimizedPalette = Truecodecs.Save(image, outStreamRaw, RasterImageFormat.Raw, 0)' Save information about this image so we can use it to load the RAW filemyRawData = New RawData()myRawData.Width = image.WidthmyRawData.Height = image.HeightmyRawData.BitsPerPixel = image.BitsPerPixelmyRawData.ViewPerspective = image.ViewPerspectivemyRawData.Order = image.OrdermyRawData.XResolution = image.XResolutionmyRawData.YResolution = image.YResolutionmyRawData.Offset = 0myRawData.Padding = TruemyRawData.ReverseBits = True' We dont need the image anymoreimage.Dispose()' Now load this RAW image back' First subscribe to the LoadInformation event so we can set the image informationAddHandler codecs.LoadInformation, AddressOf codecs_LoadInformation' Load the imageimage = codecs.Load(outStreamRaw)' Unsubscribe from the eventRemoveHandler codecs.LoadInformation, AddressOf codecs_LoadInformation' save it as bmp for testingcodecs.Save(image, outStreamBmp, RasterImageFormat.Bmp, 0)' Clean upimage.Dispose()End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
