Creates an array of RasterColor objects that represent the Netscape Fixed palette.
public static [Leadtools.RasterColor[]](rastercolor.html) Netscape()
Public Shared Function Netscape() As Leadtools.RasterColor()
public:
static Leadtools.array<RasterColor>^ Netscape();
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using LeadtoolsExamples.Common;
public void NetscapePaletteExample()
{
string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");
string destFileName = Path.Combine(ImagesPath.Path, "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();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Public Sub NetscapePaletteExample()
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Netscape.bmp")
' Load the source image as 8 bits/pixel
Dim srcImage As RasterImage = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1)
' Get the netscape palette
Dim netscapePalette As RasterColor() = RasterPalette.Netscape()
' Create the new palletized image.
Dim destImage As RasterImage = 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.
Dim inBuffer As Byte() = New Byte(srcImage.Width * 3 - 1) {} ' Buffer to hold the input row.
Dim outBuffer As Byte() = New Byte(srcImage.Width - 1) {} ' Buffer to hold the output row.
' Use DitherLine method to process each row in the image.
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
' 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()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.Windows.Media;
public void NetscapePaletteExample(RasterImage srcImage, Stream destStream)
{
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
// 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,
null,
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, destStream, RasterImageFormat.Bmp, 8);
// Cleanup
srcImage.Dispose();
destImage.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.Windows.Media
Public Sub NetscapePaletteExample(ByVal srcImage As RasterImage, ByVal destStream As Stream)
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
' Get the netscape palette
Dim netscapePalette As RasterColor() = RasterPalette.Netscape()
' Create the new palletized image.
Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, 8, srcImage.Order, srcImage.ViewPerspective, netscapePalette, Nothing, 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.
Dim inBuffer As Byte() = New Byte(srcImage.Width * 3 - 1) {} ' Buffer to hold the input row.
Dim outBuffer As Byte() = New Byte(srcImage.Width - 1) {} ' Buffer to hold the output row.
' Use DitherLine method to process each row in the image.
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
' End the dithering process.
srcImage.StopDithering()
destImage.Release()
srcImage.Release()
' Save the destination image
codecs.Save(destImage, destStream, RasterImageFormat.Bmp, 8)
' Cleanup
srcImage.Dispose()
destImage.Dispose()
End Sub
Products |
Support |
Feedback: Netscape Method - Leadtools |
Introduction |
Help Version 19.0.2017.6.19
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.