ImageGear for C and C++ on Windows v19.10 - Updated
Dithering, Anti-Aliasing, and Palette Handling
User Guide > How to Work with... > Common Operations > Viewing > Display Options > Dithering, Anti-Aliasing, and Palette Handling

ImageGear supports automatic dithering of source images. This functionality is affected by the following options:

DitherMode (AT_MODE)

Can be assigned the following values:

  • IG_DSPL_DITHER_AUTO - Specifies that the destination device color resolution should be used for dithering. In this mode, ImageGear automatically applies dithering only when it is necessary.
  • IG_DSPL_DITHER_TO_8BPP - This mode forces ImageGear to assume that the output device is 8 bits per pixel and perform the necessary dithering.
  • IG_DSPL_DITHER_TO_4BPP - This mode forces ImageGear to assume that the output device is 4 bits per pixel and perform the necessary dithering.
  • IG_DSPL_DITHER_TO_1BPP - This mode forces ImageGear to assume that the output device is 1 bit per pixel and perform the necessary dithering.
  • IG_DSPL_DITHER_NONE - Disables ImageGear's dithering. In this mode, dithering is performed by the operating system or the device driver.

The following flags can be used with any of the above modes:

IG_DSPL_DITHER_FIXED_PALETTE If this flag is set, ImageGear will try to use the standard palette when performing dithering. This may be useful if the output device contains more than one image and by using this flag it is possible to draw images with the same palette.
PALETTE This flag is applicable only if the output device is 8 bits per pixel. It tells ImageGear to use the 216 entries Netscape palette. The default value for DitherMode is IG_DSPL_DITHER_AUTO. Currently only ordered dithering is implemented.
IG_DSPL_ANTIALIAS_MODE (AT_MODE) A bitmask used to isolate black and white anti-aliasing modes:
  • IG_DSPL_ANTIALIAS_NONE - Anti-aliasing is not used.
  • IG_DSPL_ANTIALIAS_SCALE_TO_GRAY - The scale to gray algorithm is used, and the output image becomes 4 bits per pixel.
  • IG_DSPL_ANTIALIAS_PRESERVE_BLACK - ImageGear will try to preserve black pixels while scaling.
  • IG_DSPL_ANTIALIAS_PRESERVE_WHITE - ImageGear will try to preserve white pixels while scaling.
Together with these modes, the following flag can be used:
  • IG_DSPL_ANTIALIAS_SUBSAMPLE - ImageGear will use sub-sampling during anti-alias scaling. The output is as good, while the speed is greater.
IG_DSPL_ANTIALIAS_RESAMPLE_MODE A bitmask used to isolate re-sampling modes:
  • IG_DSPL_ANTIALIAS_RESAMPLE_BILINE - Resample with bilinear interpolation.
IG_DSPL_ANTIALIAS_COLOR_MASK A bitmask used to isolate color anti-aliasing modes:
  • IG_DSPL_ANTIALIAS_COLOR - Color anti-aliasing.
AliasThreshold (UINT)

Threshold integer value from 0 to 100. Its meaning depends on the AliasMode value.

  • If AliasMode is set to IG_DSPL_ANTIALIAS_SCALE_TO_GRAY, then AliasThreshold determines how many black and white pixels are involved in the destination gray pixel value. A value of 100 causes ImageGear to take 100% white pixels; a value of 0 causes ImageGear to take 100% of black pixels; and the default value is 50, which means 50% of white and 50% of black pixels.
  • If AliasMode is set to IG_DSPL_ANTIALIAS_PRESERVE_BLACK, then AliasThreshold determines how many black pixels should be preserved. A value of 100 means that 100% of black pixels are preserved. The default value is 50.
  • If AliasMode is set to IG_DSPL_ANTIALIAS_PRESERVE_WHITE, then AliasThreshold determines how many white pixels should be preserved. A value of 100 means that 100% of white pixels are preserved. The default value is 50.
DevicePalette (HPALETTE) This option is a palette in OS-dependent format. This palette is implemented before drawing pixels onto the output device. By default, this option is NULL, which means that it is created every time; either from the logical palette of the image, or from the logical palette used in dithering. If this option is not NULL, then it should be a valid palette handle. ImageGear does not perform logical processing of the specified palette; it only implements it before drawing. Incorrect usage of this option may distort the image on the destination device.
PaletteMode (AT_MODE)

This option specifies how to use the DevicePalette option when the destination device does support palette operations. Possible values are:

  • IG_DSPL_PALETTE_HIGH - ImageGear will use the palette in the high priority mode. This means that the operating system palette manager will try to best map colors of DevicePalette to the system palette.
  • IG_DSPL_PALETTE_LOW - ImageGear will use the palette in the low priority mode. In this mode, the palette manager will try to best preserve the current view of the destination while drawing the new image on it.
  • IG_DSPL_PALETTE_DISABLE - ImageGear will not implement DevicePalette in the destination device while drawing the image.