Picturize method (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int Picturize (System::AnsiString sDirectory, int iFlags, int nCellWidth, int nCellHeight);

Delphi Syntax

Picturize (sDirectory : String ; iFlags, nCellWidth, nCellHeight : Integer): Integer;

Overview

Refer to Combining Images.

Remarks

Replaces the current image with an image created from images contained in the specified directory. The image, or selected region, is broken down into rectangles of size nCellWidth x nCellHeight. For each rectangle, the image in the directory that is best suited to replace that rectangle is inserted into the original image.

The quality of the result is controlled by three factors:

1. the number of images present in the directory (the more images, the better).

2. the size of the rectangles. Smaller rectangles create an image that more closely resembles the original.

3. the type of image being replaced. If you are replacing a small image with lots of detail, then you will need lots of images in the directory in order to create an image that closely resembles the original.

PICTURIZE_ONCE and PICTURIZE_EQUALUSAGE flags cannot be combined in the iFlags parameter.

If PICTURIZE_BESTFIT is set, then nCellWidth and nCellHeight are used as a starting point for the actual cell size. The cell sizes are modified so that the size of the last rectangle in a row or column differs from the other rectangles by one. Note that the cell width and height are chosen to be smaller than nCellWidth and nCellHeight. For example, if the bitmap is 101x131 and you pass 32 for the cell width and height and set PICTURIZE_BESTFIT, then the actual cell size will be 25x32. The widths of the cells will be 26, 25, 25, 25 (for a total of 101). The heights of the rows will be 33, 33, 33, 32 (for a total of 131). This option should be used if the bitmap width and height are not multiples of nCellWidth and nCellHeight.

If the bitmap width and height are not multiples of nCellWidth and nCellHeight and PICTURIZE_BESTFIT is not passed, then the last rectangle in a row or column might be very small. Using the example given above, if PICTURIZE_BESTFIT is not set, the widths of the cells would be 32, 32, 32, 5 and the heights would be 32, 32, 32, 32, 3.

PICTURIZE_EQUALUSAGE and PICTURIZE_ONCE will reduce the number of times a bitmap is used by this method.

image\sqrblit.gif When PICTURIZE_ONCE is set, the method will try not to use the same bitmap twice. Note that if there aren’t enough images, the method will return the ERROR_NOT_ENOUGH_IMAGES code if this flag is set.

image\sqrblit.gif When PICTURIZE_EQUALUSAGE is set, the method will use the same image more than once only if it is necessary to successfully complete the picturize process. If PICTURIZE_EQUALUSAGE is set, then for any bitmap, the number of times it is used differs from the number of times another bitmap is used by at most one. Therefore, most bitmaps will be used ‘n’ times, but some bitmaps will be used ‘n+1’ times.

This method supports 12 and 16-bit grayscale and 48 and 64-bit color images. Supportfor 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.

This method does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this method.

See Also

Topics:

Raster Images: Combining Images

 

Examining and Altering Bitmaps