L_PuzzleEffectBitmap

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_PuzzleEffectBitmap( 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 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

pBitmap

Pointer to the bitmap handle referencing the bitmap to be modified.

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 the uXBlock and uYBlock parameters as the width and height of each block, in pixels.

 

PUZZLE_COUNT

[0x0020] Apply the puzzle effect using the 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.

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

Functions:

L_MosaicBitmap, L_PicturizeBitmap, L_PicturizeBitmapList, L_PicturizeBitmapSingle, L_PixelateBitmap, L_CubismBitmap, L_DiceEffectBitmap, L_RingEffectBitmap, L_BricksTextureBitmap, L_CanvasBitmap, L_CloudsBitmap, L_ColoredBallsBitmap, L_DiffuseGlowBitmap, L_DisplaceMapBitmap, L_FragmentBitmap, L_HalfTonePatternBitmap, L_MaskConvolutionBitmap, L_MosaicTilesBitmap, L_OffsetBitmap, L_PerspectiveBitmap, L_PlasmaFilterBitmap, L_PointillistBitmap, L_RomanMosaicBitmap, L_VignetteBitmap, L_ZigZagBitmap

Topics:

Raster Image Functions: Artistic Effects

 

Applying Artistic Effects

 

Using Color Values in LEADTOOLS

Example

/* This example loads a bitmap and applies a Puzzle 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 Puzzle Effect to this bitmap */
L_PuzzleEffectBitmap 
(&LeadBitmap, 10, 10, 0, PUZZLE_BORDER | PUZZLE_SHUFFLE | PUZZLE_COUNT | BITMAP_RESIZE, RGB(0,0,0));