Reserved Property (original) (raw)
Summary
The Reserved component of this RasterColor structure.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[XmlIgnoreAttribute()]
public byte Reserved { get; set; }
@property (nonatomic, assign) unsigned char reserved
public int getReserved();
public void setReserved(
int intValue
);
public:
property byte Reserved {
byte get();
void set ( byte );
}
Property Value
The reserved component of this RasterColor structure (LEADTOOLS toolkits sometimes use the Reserved component, other times the RasterColor.A component).
The Reserved component is used mostly when generating optimized palettes using Leadtools.ImageProcessing.ColorResolutionCommand to indicate whether the color is Regular, Reserved or Empty. See ColorResolutionCommand and Optimized Options for more details.
This property can be set to one of the following values:
- 0 - Indicates the color is a Regular color. This palette entry will not be changed when generating an optimized palette.
- 1 - Indicates the color is Reserved. This color will be used when generating an optimized palette. This value is equal to RasterColor.ReservedColor.
- 2 - Indicates the color is Empty. This color will be filled with an optimized color generated from the colors present in the image. This value is equal to RasterColor.EmptyColor.
The Reserved component will determine the value of RasterColor.IsReservedColor and RasterColor.IsEmptyColor properties. Changing the value RasterColor.IsReservedColor will change the value of RasterColor.Reserved and vice versa.
If 'color' is a RasterColor object, the following C# statements are equivalent:
- color.Reserved = 1;
- color.IsReservedColor = true;
- color.Reserved = RasterColor.ReservedColor;
Example
C#
// This C# example assumes 'image' is a 24/32/48/64-bit bitmap. It converts it to an optimized palette of 255 colors.
// In this case, pick a color for 'palette[0]' and let the other 255 entries be filled by ColorResolutionCommand.
private static void TestCustomOptimizedPalette(RasterImage image)
{
RasterColor[] palette = new RasterColor[256];
// Pick a color for the first palette entry (for example, a bitmap with a transparent color).
// In this case, set this entry to a color that is not in the image and then fill the transparent area with this color.
palette[0] = new RasterColor(1, 1, 1);
palette[0].IsReservedColor = true; // Mark this color as reserved
// Mark all the other palette entries as empty, so ColorResolutionCommand will fill them
for (int i = 1; i <= 255; i++)
palette[i].IsEmptyColor = true; // Mark all remaining palette entries as empty
ColorResolutionCommand cmd =
new ColorResolutionCommand(ColorResolutionCommandMode.InPlace,
8,
RasterByteOrder.Rgb,
RasterDitheringMethod.FloydStein,
ColorResolutionCommandPaletteFlags.Optimized,
null);
cmd.SetPalette(palette);
cmd.Run(image);
// Now 'image' is an 8-bit image with a palette. If you do 'RasterColor[] imagePalette = image.GetPalette()':
// - imagePalette[0] should be the selected color
// - imagePalette[1], imagePalette[2], ... imagePalette[255] should be various colors chosen by the ColorResolution command
}