LBitmap::PuzzleEffect
#include "ltwrappr.h"
virtual L_INT LBitmap::PuzzleEffect( uXBlock, uYBlock, uRandomize, uFlags, crColor);
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 randomization process */ |
L_UINT uFlags; |
/* flags that specify how to apply the puzzle effect */ |
COLORREF crColor; |
/* border color */ |
Splits the image into square blocks and randomizes these blocks inside the image. This function is available in the Raster Pro and above toolkits.
Parameter |
Description | |
uXBlock |
If the PUZZLE_SIZE flag is set, this value represents the width of the each block, in pixels. If the PUZZLE_COUNT flag is set, it represents the number of blocks per row. | |
uYBlock |
If the PUZZLE_SIZE flag is set, this value represents the height of the each block, in pixels. If the PUZZLE_COUNT flag is set, it represents 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 starting point. | |
uFlags |
Flags that specify how to apply the puzzle effect. Possible values are: | |
|
Value |
Meaning |
|
PUZZLE_BORDER |
[0x0001] Draw borders around the puzzle blocks. Use the crColor parameter to pass the border color. 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. |
|
PUZZLE_SHUFFLE |
[0x0002] Shuffle the blocks around, controlling the randomization process by the uRandomize parameter. If this flag is not set, the blocks will stay in their original position. |
|
PUZZLE_SIZE |
[0x0010] Apply the puzzle effect using the uXBlock and uYBlock parameters as the width and height of each block, in pixels. |
|
PUZZLE_COUNT |
[0x0020] Apply the puzzle effect using the uXBlock and uYBlock parameters as the number of blocks per row and per column. |
|
BITMAP_RESIZE |
[0x0100] Resize the image to be sure that all blocks have equal size. If this flag is not set then the remainder of the image (edge blocks) will be manipulated differently than the inner blocks. |
crColor |
If PUZZLE_BORDER is set in uFlags, this value represents the color of the border that will be drawn around the blocks. This parameter is ignored if the PUZZLE_BORDER flag is not 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.
Splits the image into a certain number of blocks according to the flags passed to it. If the PUZZLE_SIZE flag is set, then the image will be divided into blocks using the uXBlock and uYBlock parameters for the dimensions of the blocks. If the PUZZLE_COUNT flag is set, then the image will be divided into blocks using the uXBlock and uYBlock parameters for the number of blocks per row and number of blocks per column.
If the BITMAP_RESIZE flag is not set, the edge blocks might have a different size than the inner blocks. This means the edge blocks will be manipulated differently than the inner blocks. The inner blocks that have the same dimensions will be shuffled around. The right edge blocks will be shuffled together and the bottom edge blocks will be shuffled together.
If the BITMAP_RESIZE flag is set, the image will be resized to be sure that all blocks have the same dimensions. In this case, the edge blocks will not be treated differently than the inner blocks.
If the PUZZLE_BORDER flag is set, borders will be drawn with the color passed by the crColor parameter. If this flag is not set, no borders will be drawn.
If the PUZZLE_SHUFFLE flag is not set, the blocks will appear in their original positions. If this flag is set then the blocks will appear randomized. The randomization process will be controlled by the uRandomize parameter as follows:
If uRandomize is set to 0, the function will select the starting point for the randomize process. You will get a different result every time you call the function with uRandomize = 0.
If you set uRandomize to > 0, the function will use this value as a starting point for the randomize process. You will get the same result every time you call the function with the same value of uRandomize > 0.
Edge blocks that have the same size as inner blocks might move into the middle of the resulting image. Edge blocks with a different size than inner blocks will remain on the edge.
You must set PUZZLE_SIZE or PUZZLE_COUNT (but not both) for the function to affect the image. If you pass 0 for uFlags, the function leaves the image unchanged.
This function 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.
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
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.
See Also
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. |
Example
void TestFunction(LBitmap *pLeadBitmap)
{
/* This example applies a Puzzle Effect over the loaded image. */
/* Apply Puzzle Effect to this bitmap */
pLeadBitmap->PuzzleEffect (10, 10, 0, PUZZLE_BORDER | PUZZLE_SHUFFLE | PUZZLE_COUNT | BITMAP_RESIZE, RGB(0,0,0));
}