Reduces the number of colors in an image.



Canvas.ReduceColors inPlt, inCols, inDither


Name   Type   Description
inPlt Variant or Object The palette to use for color reduction - see below.
inCols Long The number of colors that should be used.
inDither Boolean Whether to dither the final image.



This method allows you to do color reduction on a canvas using a variety of palette, dither and color options.

You can use many formats of palette. If you want ImageGlue to derive a palette for you then just specify one of the standard Palette parameter string options. Additionally you may need to supply a number of colors for the palette.

If you want to use a palette from a file - typically an act file - then supply the path to that file.

If you want to use a raw palette derived from some other source then provide the raw data. You may obtain such information using the GetInfo method or by reading an act file into memory.

Raw palettes consist of an array of 768 bytes holding 256 RGB triplets. Additionally ImageGlue will handle RGBA data.

The dither parameter determines whether dithering is performed when the colors in the image are reduced. ImageGlue uses a highly optimized Floyd-Steinberg diffusion dither for speed and quality.

Please note that video drivers expect that colors like black and white will always be present in an image. ImageGlue may remove these colors if they are not required. This means you may have problems drawing color reduced canvasses onto other canvasses.

See Also




Set ca = Server.CreateObject("ImageGlue7.Canvas")
ca.DrawFile Server.MapPath("birds.jpg"), ""
ca.ReduceColors "grayscale", 64, True
ca.SaveAs Server.MapPath("gray.jpg"), ""

The code above draws an image onto a canvas. It then reduces the image to a 64 level grayscale image and saves it as a JPEG. Two sample images are shown below.