|
||
|
Quantising BitmapsThis sample was inspired by a T-Shirt I bought which used circles of various sizes to represent the intensity level of a blown-up image. The image is easy to see at a distance but not so straightforward close-up (which is handy, as I'm no oil-painting close-up). The code demonstrates averaging the pixels in an image and then creating a new image with one which uses an image from a strip which corresponds to the intensity at that point, optionally setting the colour to match the original. About the DemonstrationThe main demonstration screen is split into three parts:
The image strip source is used to represent the different intensities in the result image. You can select the number of images in the strip (the image at the left-hand edge should be the darkest and the one at the rightmost edge the lightest). This image can be scaled (using alpha resampling) and you so you can also specify the transparent colour, which is normally picked automatically from the top-right corner. Ideally the image strip source should be a much larger bitmap than needed, and scaled down to get a smooth effect. Once a source image is loaded you can then create a quantised output. The options here are:
Some examples of the output are as follows: About the CodeThe quantising code is mostly applied by the cDibQuantiser class. Ignoring the code to set up the quantise image, source and result, all of the work is performed in the pQuantise method. The code runs through a few steps:
ConclusionThis article demonstrates applying quantising effects to images. The code here can also be used to create other effects such as mosaics.
|
|
|