#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_CubismBitmap(pBitmap, uSpace, uLength, nBrightness, nAngle, crColor,uFlags)


pointer to the bitmap handle

L_UINT uSpace;

cube spaces

L_UINT uLength;

cube side length

L_INT nBrightness;


L_INT nAngle;

cube orientation


background color

L_UINT uFlags;


Remaps the bitmap into a collection of rotated rectangles (cubic faces) so that it appears to have been created in the Cubist art style.

Parameter Description
pBitmap Pointer to the bitmap handle referencing the bitmap to be changed.
uSpace Space between cubes, in pixels. As uSpace decreases the concentration of cubes increases and vice versa. The valid range is from 1 to the image or region dimension (that is, min(Height, Width))
uLength Cube side length, in pixels.
nBrightness A value that indicates the brightness of the bitmap. This value can be a number between -1000 and 1000. Negative values darken the image and positive values lighten the image.
nAngle The cubes angle of orientation, in hundredths of a degree (+/-). This value is ignored if the CUB_RAND flag has been set in uFlags. Possible values are from36000 to 36000.
crColor The COLORREF value that specifies the background color. This value is ignored if the CUB_BKG flag has been set in uFlags.
uFlags Flags that indicate the background color, cube shape and cube orientation. You can use a bit wise OR (|) to specify one flag from each group.
  The following are the flags that indicate the background color:
  Value Meaning
  CUB_BKG [0x0001] Use the image itself as the background.
  CUB_COLOR [0x0002] Use the color in the crColor member as the background color.
  The following are the flags that indicate the cubes shape:
  Value Meaning
  CUB_SQR [0x0010] Cubes will have square shape.
  CUB_RECT [0x0020] Cubes will have rectangular shape.
  The following are the flags that indicate the cubes orientation:
  Value Meaning
  CUB_RAND [0x0100] Cubes will have random orientation.
  CUB_ORNT [0x0200] All cubes will have the orientation specified by the nAngle value.



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 remaps the bitmap into a collection of rotated rectangles (cubic faces), producing an image in a Cubist style.

For an example, click here

To obtain this effect, the following settings were used with the function:

uSpace = 5
uLength = 10
nBrightness = 0
nAngle = 0
crColor = RGB(0,0,0)

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


For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.


Win32, x64, Linux.

See Also


L_AddBitmapNoise, L_EmbossBitmap, L_MosaicBitmap, L_MotionBlurBitmap, L_OilifyBitmap, L_PosterizeBitmap, L_RemoveRedeyeBitmap, L_SolarizeBitmap, L_UnderlayBitmap, L_BumpMapBitmap, L_DrawStarBitmap, L_DryBitmap, L_FreePlaneBendBitmap, L_FreeRadBendBitmap, L_GlassEffectBitmap, L_GlowFilterBitmap, L_LensFlareBitmap, L_LightBitmap, L_OceanBitmap, L_PlaneBendBitmap, L_PlaneBitmap, L_SampleTargetBitmap, L_TunnelBitmap, L_BendingBitmap, L_CylindricalBitmap, L_FreeHandShearBitmap, L_FreeHandWaveBitmap, L_ImpressionistBitmap, L_PixelateBitmap, L_PolarBitmap, L_PunchBitmap, L_RadialBlurBitmap, L_RadWaveBitmap, L_RippleBitmap, L_SpherizeBitmap, L_SwirlBitmap, L_WaveBitmap, L_WindBitmap, L_ZoomBlurBitmap, L_ZoomWaveBitmap, 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, L_AdjustBitmapTint, L_ColorHalfToneBitmap


Raster Image Functions: Artistic Effects


Applying Artistic Effects


Using Color Values in LEADTOOLS


Raster Image Functions: Correcting Colors


The following example loads a bitmap and applies the cubism function to it:

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT CubismBitmapExample(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 cubism*/ 
   nRet = L_CubismBitmap(&LeadBitmap, 20,30,200,4500,RGB(255,0,0), CUB_COLOR | CUB_RECT | CUB_RAND); 
   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 
   return SUCCESS; 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help