This function changes the number of colors in a raster image.

[C++Builder]   HANDLE IKConvertColor(HANDLE Handle, short PixelType, BOOL FixedPal, BOOL Dither, BYTE Level, IKPROCESSPROC UserProc, LPCTSTR Caption, LPCTSTR Message, LPCTSTR Button);
[Delphi]   function IKConvertColor(Handle: THandle; PixelType: Smallint; FixedPal, Dither: LongBool; Level: Byte; UserProc: LONG_PTR; Caption, Message, Button: PChar): THandle;

Parameters

Name Explanation
Handle The image handle of the raster image (1, 4, 8, 16, 24, or 32 bit image)
PixelType The number of bits per pixel (1, 4, 8, 16, 24, 32, 40, 80) after the conversion.

   * 4 represents 4 bit color, 40 is for 4 bit grayscale, 8 is for 8 bit color, and 80 is for 8 bit grayscale

FixedPal Fixed palette settings (Use when decreasing or increasing to 1, 4, or 8 bit color)

   False (0): Uses a created palette most suitable for the image

   True (nonzero): Uses a fixed palette

Dither Sets the dither (error diffusion) (Use when decreasing to 1, 4, or 8 bit color or 4 bit grayscale)

   False(0): Does not dither

   True(nonzero): Dithers

Level Threshold value settings (Use when decreasing to 1 bit images)

Values range from 0 to 255

UserProc The address of the user function (If not using the user function then set to 0)
Caption Sets the text displayed in the title bar of the progress dialog box
Message Sets the message displayed in the progress dialog box
Button Sets the name of the button displayed in the progress dialog box

Return Value

Returns the raster image handle if successful. Returns 0 if unsuccessful.

Explanation

The IKConvertColor function changes the number of colors in a raster image.

When decreasing the number of colors of an image to 1 bit color, if the RGB value (an average of the red, green, and blue values) is less than the threshold value, the palette is set to 0. If the RGB value (an average of the red, green, and blue values) is more than the value set in the Level parameter, it is set to 1. If the specified RGB values can not be selected, a black image is created.


Note: the image handles passed to IKSELECT_IMAGE are NOT automatically freed after executing this function.


If the user function is set or if the Caption, Message, and Button parameters are blank then the Progress dialog box is not displayed. If the Progress dialog box is displayed, it indicates the percentage of the current process completed. For more information about the user function please refer to the Definition of User Function in the Ik10Effect.dll, Ik10EffectA.dll, Ik10Effect64.dll, Ik10Effect64A.dlll section.

 

The ImageKit10 VCL is a product created by Newtone Corporation