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.
L_LTIMGSFX_API L_INT L_DiceEffectBitmap (pBitmap, uXBlock, uYBlock, uRandomize, uFlags, crColor);
Pointer to the bitmap handle referencing the bitmap to be modified.
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.
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.
The starting point for the randomization process. Valid values range from 0 through 500. Use 0 to have the function select the value.
Flags that specify how to apply the effect. Possible values are:
|DICE_BORDER||[0x0001] Draw borders around the dice blocks. The border color is given by
|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.|
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.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
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.
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
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:
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):
The starting point (that is, the "randomize value") for the random number generator is selected through the
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:
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 in the Document and Medical Imaging 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 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Dice Effect Function - Before
Dice Effect Function - After
View additional platform support for this Dice Effect function.
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 */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image2.jpg")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
/* Apply Dice Effect for this bitmap */
nRet = L_DiceEffectBitmap (&LeadBitmap, 16, 16,0, BITMAP_RESIZE | DICE_SIZE | DICE_BORDER, RGB(0,0,0));
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries