public static RasterColor[] Netscape()
public static RasterColor[] netscape();
public:
static array<RasterColor>^ Netscape();
def Netscape(self):
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
public void NetscapePaletteExample()
{
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Netscape.bmp");
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
// Load the source image as 8 bits/pixel
RasterImage srcImage = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1);
// Get the netscape palette
RasterColor[] netscapePalette = RasterPalette.Netscape();
// Create the new palletized image.
RasterImage destImage = new RasterImage(
RasterMemoryFlags.Conventional,
srcImage.Width,
srcImage.Height,
8,
srcImage.Order,
srcImage.ViewPerspective,
netscapePalette,
IntPtr.Zero,
0);
// Set the dithering method.
srcImage.DitheringMethod = RasterDitheringMethod.StevensonArce;
srcImage.Access();
destImage.Access();
// Initialize the dithering process.
srcImage.StartDithering(netscapePalette, 256);
// Allocate the output buffer for 8-bit data.
byte[] inBuffer = new byte[srcImage.Width * 3]; // Buffer to hold the input row.
byte[] outBuffer = new byte[srcImage.Width]; // Buffer to hold the output row.
// Use DitherLine method to process each row in the image.
for (int i = 0; i < srcImage.Height; i++)
{
srcImage.GetRow(i, inBuffer, 0, srcImage.BytesPerLine);
srcImage.DitherLine(inBuffer, 0, outBuffer, 0);
destImage.SetRow(i, outBuffer, 0, destImage.BytesPerLine);
}
// End the dithering process.
srcImage.StopDithering();
destImage.Release();
srcImage.Release();
// Save the destination image
codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 8);
// Cleanup
srcImage.Dispose();
destImage.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\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