L_PuzzleEffectBitmap

#include "l_bitmap.h"

L_LTIMGSFX_API L_INT L_PuzzleEffectBitmap(pBitmap, uXBlock, uYBlock, uRandomize, uFlags, crColor);

Splits the image into square blocks and randomizes these blocks inside the image.

Parameters

pBITMAPHANDLE pBitmap

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

L_UINT 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.

L_UINT 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.

L_UINT 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.

L_UINT 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.

COLORREF 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

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

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.

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 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.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example loads a bitmap and applies a Puzzle Effect over the loaded image.

L_INT PuzzleEffectBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   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);  
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* Apply Puzzle Effect to this bitmap */ 
   nRet = L_PuzzleEffectBitmap (&LeadBitmap, 10, 10, 0, PUZZLE_BORDER | PUZZLE_SHUFFLE | PUZZLE_COUNT | BITMAP_RESIZE, RGB(0,0,0));  
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   if(LeadBitmap.Flags.Allocated)   
      L_FreeBitmap(&LeadBitmap);   
   return SUCCESS; 
} 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help