Creates an array of
RasterColor objects that represent the Netscape Fixed palette.
Syntax
Visual Basic (Declaration) | |
---|
Public Shared Function Netscape() As RasterColor() |
Example
Visual Basic | Copy Code |
---|
Public Sub NetscapePaletteExample()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"
Dim destFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_Netscape.bmp"
Dim srcImage As RasterImage = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1)
Dim netscapePalette As RasterColor() = RasterPalette.Netscape()
Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, 8, srcImage.Order, srcImage.ViewPerspective, netscapePalette, IntPtr.Zero, 0)
srcImage.DitheringMethod = RasterDitheringMethod.StevensonArce
srcImage.Access()
destImage.Access()
srcImage.StartDithering(netscapePalette, 256)
Dim inBuffer As Byte() = New Byte(srcImage.Width * 3 - 1) {}
Dim outBuffer As Byte() = New Byte(srcImage.Width - 1) {}
Dim i As Integer = 0
Do While i < srcImage.Height
srcImage.GetRow(i, inBuffer, 0, srcImage.BytesPerLine)
srcImage.DitherLine(inBuffer, 0, outBuffer, 0)
destImage.SetRow(i, outBuffer, 0, destImage.BytesPerLine)
i += 1
Loop
srcImage.StopDithering()
destImage.Release()
srcImage.Release()
codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 8)
srcImage.Dispose()
destImage.Dispose()
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
public void NetscapePaletteExample() { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"; string destFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_Netscape.bmp"; // 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(); RasterCodecs.Shutdown(); } |
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also