L_DiceEffectBitmap
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_DiceEffectBitmap (pBitmap, uXBlock, uYBlock, uRandomize, uFlags, crColor);
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
L_UINT uXBlock; |
/* either the width of the block or the number of blocks per row */ |
L_UINT uYBlock; |
/* either the height of the block or the number of blocks per column */ |
L_UINT uRandomize; |
/* starting point for the randomization process */ |
L_UINT uFlags; |
/* flags that specify how to apply the effect */ |
COLORREF crColor; |
/* border color */ |
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 function is available in the Raster Pro and above toolkits.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle referencing the bitmap to be modified. |
|
uXBlock |
If the DICE_SIZE flag is set, this parameter represents the width of the each block, in pixels. If the DICE_COUNT flag is set, this parameter represents the number of blocks per row. |
|
uYBlock |
If the user set the DICE_SIZE flag, this parameter represents the height of the each block, in pixels. If the user set the DICE_COUNT flag instead of DICE_SIZE flag, this parameter will represent the number of blocks per column. |
|
uRandomize |
The starting point for the randomization process. Valid values range from 0 through 500. Use 0 to have the function select the value. |
|
uFlags |
Flags that specify how to apply the effect. Possible values are: |
|
|
Value |
Meaning |
|
DICE_BORDER |
[0x0001] Draw borders around the dice blocks. The border color is given by crColor. Each block will draw the border on the inside of the edges. The border is 1 pixel wide. In places with adjacent blocks, the border will be 2 pixels wide because each block has a 1-pixel border. If the BITMAP_RESIZE flag is not set and the edge blocks have a different size than the inner blocks, the border will not be drawn for the right and the bottom edges. |
|
DICE_SIZE |
[0x0010] uXBlock and uYBlock contain the width and height of each block, in pixels. |
|
DICE_COUNT |
[0x0020] uXBlock and uYBlock contain the number of blocks per row and per column. |
|
BITMAP_RESIZE |
[0x0100] if this flag is set then the image will be resized to be sure that all blocks have equal size. If this flag is not set then the edge blocks might have a different size than the inner blocks. If the edge blocks have a different size, they will be manipulated differently. See the comments below for more information. |
crColor |
Value that represents the color of the border that will be drawn around the dice blocks. This parameter will be used only if the DICE_BORDER flag is set. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function 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 function divides the image into a certain number of blocks according to the uFlags 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 uXBlock and uYBlock parameters.
If the uFlags 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 uXBlock and uYBlock parameters.
The uFlags variable must contain DICE_COUNT or DICE_SIZE (but not both).
The uFlags 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 function works in the following manner:
It divides the image into a certain number of blocks.
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.
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.
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 function draws borders around the blocks.
The starting point (that is, the "randomize value") for the random number generator is selected through the uRandomize parameter.
If uRandomize is set to zero then the function itself selects a random value between 1 and 500 for the randomize value.
If uRandomize is > 0, it is used for the randomize value.
Here are some tips related to the randomize point:
The sequence of generated random numbers is the same if you use the same randomize value > 0. In other words, if you call the function twice with the same randomize value, each block will be transformed the same way.
Calling the function 4 times with the same bitmap and the same randomize value > 0 will leave the bitmap blocks unchanged. So, if you call the function once, the blocks will be transformed. Call the function 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 uFlags, the function leaves the image unchanged.
This function supports all bits/pixel supported by LEADTOOLS.
This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
To update a status bar or detect a user interrupt during execution of this function, Refer to L_SetStatusCallback.
This function 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 function.
Required DLLs and Libraries
LTIMG For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Windows 95 / 98 / Me, Windows 2000 / XP.
See Also
Example
/* This example loads a bitmap and applies a Dice Effect over the loaded image. */
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
/* Load the bitmap, keeping the bits per pixel of the file */
L_LoadBitmap (TEXT("IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
/* Apply Dice Effect for this bitmap */
L_DiceEffectBitmap (&LeadBitmap, 16, 16,0, BITMAP_RESIZE | DICE_SIZE | DICE_BORDER, RGB(0,0,0));