DiceEffect method (ILEADRasterProcess)

Visual Basic example

Visual C++ example

 

Syntax

short DiceEffect (ILEADRaster *pRaster, ong lXBlock, long lYBlock, long lRandomize, OLE_COLOR crColor, long lFlags);

Overview

Refer to Applying Artistic Effects

Remarks

(Raster Pro and above toolkits) Splits the image into square or rectangular blocks. If the blocks are square, rotates each block by 0, 90, 180, or 270 degrees. If the blocks are rectangular, flips the blocks around the X-axis or Y-axis.

This method can process the whole image or a region of the image. If a bitmap has a region, the effect is applied only to the region.

This method divides the image into a certain number of blocks according to the lFlags parameter. If this flag is set to DICE_SIZE then the image will be divided into blocks according to the width and height for each block, which you set with the lXBlock and lYBlock parameters.

If the lFlags flag is set to DICE_COUNT then the image is divided into blocks according to the number of blocks per row and number of blocks per column you set with the lXBlock and lYBlock parameters.

The lFlags variable must contain DICE_COUNT or DICE_SIZE (but not both).

The lFlags variable can be or-ed with the DICE_BORDER and BITMAP_RESIZE flags. If the DICE_BORDER flag is set, borders will be drawn around the dice blocks and it will be painted by the crColor parameter. If the BITMAP_RESIZE flag is set then the image will be resized so that all blocks have the same size and so there is no remainder in the image, ensuring that all blocks in the image will be manipulated in the same way. If the BITMAP_RESIZE flag is not set then the edge blocks (which may be a different size than the inner blocks) will be treated differently than the inner blocks.

The Dice effect method works in the following manner:

It divides the image into a certain number of blocks.

image\sqrblit.gif If the BITMAP_RESIZE flag is set, the bitmap is resized to the closest size to have the edge blocks have the same size as the inner blocks.

image\sqrblit.gif If the BITMAP_RESIZE flag is not set, then the inner blocks might have a different size and shape than the edge blocks. Each block is transformed according to its shape.

image\sqrblit.gif For each block, a rotation angle is picked at random out of the following values: 0, 90, 180, and 270. The rotation angle is applied depending on the block shape (square or rectangular):

If the block is square, it is rotated by the rotation angle.

If the block is rectangular, it is transformed as follows:

If the rotation angle is 0, the block remains unchanged.

If the rotation angle is 90, the block is flipped around the x-axis.

If the angle is 180, the block is rotated by 180.

If the angle is 270, the block is flipped around the y-axis.

If the DICE_BORDER flag is set, the method draws borders around the blocks.

The starting point (that is, the "randomize value") for the random number generator is selected through the lRandomize parameter.

image\sqrblit.gif If lRandomize is set to zero then the method itself selects a random value between 1 and 500 for the randomize value.

image\sqrblit.gif If lRandomize is > 0, it is used for the randomize value.

Here are some tips related to the randomize point:

image\sqrblit.gif The sequence of generated random numbers is the same if you use the same randomize value > 0. In other words, if you call the method twice with the same randomize value, each block will be transformed the same way.

image\sqrblit.gif Calling the method 4 times with the same bitmap and the same randomize value > 0 will leave the bitmap blocks unchanged. So, if you call the method once, the blocks will be transformed. Call the method 3 more times and each block goes to its original transformation. Of course, if you elected to draw borders, there will be a grid drawn on the image.

If you pass 0 for lFlags, the method leaves the image unchanged.

This method supports all bits/pixel supported by LEADTOOLS.

Support for 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

Elements:

PuzzleEffect method, RingEffect method.

Topics:

Raster Images: Artistic Effects

 

Using Color Values in LEADTOOLS