public RasterNativeBuffer DecodeAbic(RasterNativeBuffer inputData,int align,int width,int height,bool biLevel)
public RasterNativeBuffer decodeAbic(RasterNativeBuffer inputData, int align, int width, int height, boolean biLevel) public:RasterNativeBuffer DecodeAbic(RasterNativeBuffer inputData,int align,int width,int height,bool biLevel)
inputData
A RasterNativeBuffer object which contains the input data.
align
Number of bytes to align the uncompressed output data.
width
Image width, in pixels.
height
Image height, in pixels.
biLevel
true to indicate bi-level encoding, false to indicate 4-bit grayscale encoding.
A RasterNativeBuffer object that contains the raw uncompressed data.
Call this method to decompress the input 1-bit bi-level or 4-bit grayscale ABIC data.
Use EncodeAbic to encode ABIC data.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;public void EncodeDecodeAbic4BitExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp");string destDataFile = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Abic_4Bit.bmp");// Load the file save it to a memory stream as RAWDebug.WriteLine("Loading the source image as 1 bits/pixel");RasterImage srcImage = codecs.Load(srcFileName, 0, CodecsLoadByteOrder.Rgb, 1, 1);// Convert it to 4-bit image with optimized palette using Floyd Steinberg dithering for best quality.//// We could also load the source image straight to 4-bits per pixel,// but that operation creates a 4-bit bitmap with fixed palette and the output does not look as good.ColorResolutionCommand cmdColorRes = new ColorResolutionCommand(ColorResolutionCommandMode.InPlace,4,RasterByteOrder.Rgb,RasterDitheringMethod.FloydStein,ColorResolutionCommandPaletteFlags.Optimized,null);cmdColorRes.Run(srcImage);Debug.WriteLine("Saving the image to memory as RAW format");MemoryStream ms = new MemoryStream();codecs.Save(srcImage, ms, RasterImageFormat.Raw, srcImage.BitsPerPixel);Debug.WriteLine("Encoding the data as ABIC");byte[] rawData = ms.GetBuffer();ms.Close();// Encode this data as ABICDebug.WriteLine("Encode this data as ABIC");byte[] abicData = codecs.EncodeAbic(rawData, 1, srcImage.Width, srcImage.Height, false);// Decode the data back to RAWDebug.WriteLine("Decoding the data back as RAW");rawData = codecs.DecodeAbic(abicData, 4, srcImage.Width, srcImage.Height, false);// Create a new image from this dataRasterImage destImage = new RasterImage(RasterMemoryFlags.Conventional,srcImage.Width,srcImage.Height,srcImage.BitsPerPixel,srcImage.Order,srcImage.ViewPerspective,srcImage.GetPalette(),IntPtr.Zero,0);destImage.Access();// Add the scan linesfor (int y = 0; y < destImage.Height; y++){int bufferIndex = y * destImage.BytesPerLine;destImage.SetRow(y, rawData, bufferIndex, destImage.BytesPerLine);}destImage.Release();// Save this image to diskcodecs.Save(destImage, destDataFile, RasterImageFormat.Bmp, destImage.BitsPerPixel);srcImage.Dispose();destImage.Dispose();// Clean upcodecs.Dispose();}public void EncodeDecodeAbic1BitExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp");string destDataFile = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Abic_1Bit.bmp");// Load the file save it to a memory stream as RAWConsole.WriteLine("Loading the source image at 1 bit/pixel");RasterImage srcImage = codecs.Load(srcFileName, 1, CodecsLoadByteOrder.Rgb, 1, 1);Console.WriteLine("Saving the image to memory as RAW format");MemoryStream ms = new MemoryStream();codecs.Save(srcImage, ms, RasterImageFormat.Raw, srcImage.BitsPerPixel);Console.WriteLine("Encoding the data as ABIC");byte[] rawData = ms.GetBuffer();ms.Close();// Encode this data as ABICbyte[] abicData = codecs.EncodeAbic(rawData, 1, srcImage.Width, srcImage.Height, true);// Decode the data back to RAWConsole.WriteLine("Decoding the data back as RAW");rawData = codecs.DecodeAbic(abicData, 4, srcImage.Width, srcImage.Height, true);// Create a new image from this dataRasterImage destImage = new RasterImage(RasterMemoryFlags.Conventional,srcImage.Width,srcImage.Height,srcImage.BitsPerPixel,srcImage.Order,srcImage.ViewPerspective,srcImage.GetPalette(),IntPtr.Zero,0);destImage.Access();// Add the scan linesfor (int y = 0; y < destImage.Height; y++){int bufferIndex = y * destImage.BytesPerLine;destImage.SetRow(y, rawData, bufferIndex, destImage.BytesPerLine);}destImage.Release();// Save this image to diskcodecs.Save(destImage, destDataFile, RasterImageFormat.Bmp, destImage.BitsPerPixel);srcImage.Dispose();destImage.Dispose();// Clean upcodecs.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}
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
