Initializes the buffered dithering of an image.
public void StartDithering(Leadtools.RasterColor[] palette,int colors)
Public Sub StartDithering( _ByVal palette() As Leadtools.RasterColor, _ByVal colors As Integer _)
public void StartDithering(Leadtools.RasterColor[] palette,int colors)
- (BOOL)startDithering:(nullable NSArray<LTRasterColor *> *)palettecolors:(NSUInteger)colorserror:(NSError **)error
function Leadtools.RasterImage.StartDithering(palette ,colors)
public:void StartDithering(Leadtools.array<RasterColor>^ palette,int colors)
palette
The palette this uses for dithering. You can specify your own palette, or use a null reference for LEAD's fixed palette.
colors
Number of colors used in the palette. If the palette contains more colors, only the first colors colors are used. Valid values are 2 to 256.
The following flow chart shows how the methods relate to each other:
The following properties from the RasterImage are used to control the dithering operation:
This method does not support signed images.
For more information, refer to Introduction to Image Processing With LEADTOOLS.
This example dithers each line in one image and writes it to another image.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Dicom;using Leadtools.Drawing;using Leadtools.Controls;using LeadtoolsExamples.Common;using Leadtools.Svg;public void StartDitheringExample(){RasterCodecs codecs = new RasterCodecs();// Load an image that has BottomLeft ViewPerspectiveRasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE1.CMP"));RasterColor[] Palette = RasterPalette.Fixed(256);// Create the new palletized image.RasterImage destinationImage = new RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8, image.Order, image.ViewPerspective, Palette, IntPtr.Zero, 0);// Set the dithering method.image.DitheringMethod = RasterDitheringMethod.StevensonArce;// Initialize the dithering process.image.StartDithering(Palette, 256);// Allocate the output buffer for 8-bit data.byte[] InBuffer = new byte[image.Width * 3];// Buffer to hold the input row.byte[] OutBuffer = new byte[image.Width];// Buffer to hold the output row.// Use DitherLine method to process each row in the image.for (int i = 0; i < image.Height; i++){image.GetRow(i, InBuffer, 0, image.BytesPerLine);image.DitherLine(InBuffer, 0, OutBuffer, 0);destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine);}// End the dithering process.image.StopDithering();codecs.Save(destinationImage, Path.Combine(ImagesPath.Path, "IMAGE1_DitherLine.BMP"), RasterImageFormat.Bmp, 0);image.Dispose();destinationImage.Dispose();codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.ControlsImports Leadtools.DicomImports Leadtools.DrawingImports Leadtools.SvgPublic Sub StartDitheringExample()Dim codecs As RasterCodecs = New RasterCodecs()' Load an image that has BottomLeft ViewPerspectiveDim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"))Dim Palette As RasterColor() = RasterPalette.Fixed(8)' Create the new palletized image.Dim destinationImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8,image.Order, image.ViewPerspective, Palette, IntPtr.Zero, 0)' Set the dithering method.image.DitheringMethod = RasterDitheringMethod.StevensonArce' Initialize the dithering process.image.StartDithering(Palette, 256)' Allocate the output buffer for 8-bit data.Dim InBuffer As Byte() = New Byte(image.Width * 3 - 1) {} ' Buffer to hold the input row.Dim OutBuffer As Byte() = New Byte(image.Width - 1) {} ' Buffer to hold the output row.' Use DitherLine method to process each row in the image.Dim i As Integer = 0Do While i < image.Heightimage.GetRow(i, InBuffer, 0, image.BytesPerLine)image.DitherLine(InBuffer, 0, OutBuffer, 0)destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine)i += 1Loop' End the dithering process.image.StopDithering()codecs.Save(destinationImage, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_DitherLine.BMP"), RasterImageFormat.Bmp, 0)image.Dispose()destinationImage.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.Dicom;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Examples;using Leadtools.Windows.Media;public void StartDitheringExample(RasterImage image, Stream destStream){RasterColor[] Palette = RasterPalette.Fixed(256);// Create the new palletized image.RasterImage destinationImage = new RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8, image.Order, image.ViewPerspective, Palette, null, 0);// Set the dithering method.image.DitheringMethod = RasterDitheringMethod.StevensonArce;// Initialize the dithering process.image.StartDithering(Palette, 256);// Allocate the output buffer for 8-bit data.byte[] InBuffer = new byte[image.Width * 3];// Buffer to hold the input row.byte[] OutBuffer = new byte[image.Width];// Buffer to hold the output row.// Use DitherLine method to process each row in the image.for (int i = 0; i < image.Height; i++){image.GetRow(i, InBuffer, 0, image.BytesPerLine);image.DitherLine(InBuffer, 0, OutBuffer, 0);destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine);}// End the dithering process.image.StopDithering();RasterCodecs codecs = new RasterCodecs();codecs.Save(destinationImage, destStream, RasterImageFormat.Bmp, 0);image.Dispose();destinationImage.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.DicomImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.Windows.MediaPublic Sub StartDitheringExample(ByVal image As RasterImage, ByVal destStream As Stream)Dim Palette As RasterColor() = RasterPalette.Fixed(256)' Create the new palletized image.Dim destinationImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, image.Width, image.Height, 8, image.Order, image.ViewPerspective, Palette, Nothing, 0)' Set the dithering method.image.DitheringMethod = RasterDitheringMethod.StevensonArce' Initialize the dithering process.image.StartDithering(Palette, 256)' Allocate the output buffer for 8-bit data.Dim InBuffer As Byte() = New Byte(image.Width * 3 - 1) {} ' Buffer to hold the input row.Dim OutBuffer As Byte() = New Byte(image.Width - 1) {} ' Buffer to hold the output row.' Use DitherLine method to process each row in the image.Dim i As Integer = 0Do While i < image.Heightimage.GetRow(i, InBuffer, 0, image.BytesPerLine)image.DitherLine(InBuffer, 0, OutBuffer, 0)destinationImage.SetRow(i, OutBuffer, 0, destinationImage.BytesPerLine)i += 1Loop' End the dithering process.image.StopDithering()Dim codecs As RasterCodecs = New RasterCodecs()codecs.Save(destinationImage, destStream, RasterImageFormat.Bmp, 0)image.Dispose()destinationImage.Dispose()End Sub
Introduction to Image Processing With LEADTOOLS
Codecs.CodecsThumbnailOptions.DitheringMethod property
ImageProcessing.ColorResolutionCommand.DitheringMethod property
RasterDitheringMethod enumeration
RasterDefaults.DitheringMethod property
RasterImage.DitheringMethod property
|
Products |
Support |
Feedback: StartDithering 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.