←Select platform

Fixed Method

Summary
Creates an array of RasterColor objects that represent the LEAD Fixed palette.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public static RasterColor[] Fixed( 
   int count 
) 
+(NSArray*)fixed:(unsigned int)count; 
public static RasterColor[] fixed( 
   int count 
); 
public: 
static array<RasterColor>^ Fixed(  
   int count 
)  
def Fixed(self,count): 

Parameters

count
The number of colors to add to the fixed palette.

Return Value

The LEAD Fixed palette.

Remarks

The number of colors specified in  count controls the type and size of the returned palette:

count LEAD Fixed palette
2 1-bit palette, with 2 colors, black and white.
4 2-bit palette, with 4 colors.
8 3-bit palette, with 8 colors.
16 4-bit palette, with 16 colors.
32 5-bit palette, with 32 colors.
64 6-bit palette, with 64 colors.
128 7-bit palette, with 128 colors.
256 8-bit palette, with 256 colors.
Example
C#
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 Leadtools.Svg; 
 
 
public void StartDitheringExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   // Load an image that has BottomLeft ViewPerspective 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "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. 
   image.Access(); 
   destinationImage.Access(); 
   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); 
   } 
   destinationImage.Release(); 
   image.Release(); 
 
   // 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(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.5.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.