L_MaskConvolutionBitmap

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_MaskConvolutionBitmap(pBitmap, nAngle, uDepth, uHeight, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nAngle;

/* angle of the apparent light source */

L_UINT uDepth;

/* depth of the 3D effect */

L_UINT uHeight;

/* height of the 3D effect */

L_UINT uFlags;

/* flags */

Applies various 3d effects to a bitmap.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the target bitmap.

nAngle

Angle of apparent light source, in hundredths of degrees. Possible values range from 36000 to 36000.

uDepth

The depth of the 3D effect. (This value is divided internally by 100). This value is used as a multiplier for the individual mask values.

uHeight

Non-zero value greater than 2, that represents the height of the mask matrix. This value determines the height of the 3D effect. The larger the value, the more complex and time-consuming the operations will be.

uFlags

Flag that indicates which mask to use in the convolution process. Possible values are:

 

Value

Meaning

 

MSKC_EMBOSS

[0x0000] Apply the Emboss Mask on the Bitmap.

 

MSKC_EDGE

[0x0001] Apply the Edge Detection Mask on the Bitmap.

 

MSKC_ESPLOTCH

[0x0002] Apply the Emboss-Splotch Mask on the Bitmap.

 

MSKC_SPLOTCH

[0x0003] Apply the Splotch Mask on the Bitmap.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

For MSKC_EDGE, the results are the same for opposite angles. For example, angles 0 and 180 have the same result when used with the edge detection mask.

When an image undergoes image convolution each pixel of the image is multiplied by a mask to create a new pixel value. The mask is an array of values that describes the weight that should be given to each of the pixels surrounding a specific pixel. The new pixel value is the result of the mask sum being divided by the mask weight. Using different masks result in different alterations of the image. The masks used in this function result in different types of edge detection.

For an example, click here

To obtain these bitmaps, the following settings were used:

Parameter

Emboss

Edge

Esplotch

Splotch

nAngle

0

0

180

0

uDepth

3

3

3

3

uHeight

250

250

100

100

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

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.

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

LTIMGEFX

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

Win32, x64.

See Also

Functions:

L_PlasmaFilterBitmap, L_EmbossBitmap, L_SharpenBitmap, L_PosterizeBitmap, L_MosaicBitmap, L_AverageFilterBitmap, L_MedianFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_OilifyBitmap, L_SolarizeBitmap, L_DlgEmboss, L_WindowLevel, L_BumpMapBitmap, L_CubismBitmap, 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_AddShadowBitmap, L_RevEffectBitmap, L_AgingBitmap, L_DiceEffectBitmap, L_FunctionalLightBitmap, L_PuzzleEffectBitmap, L_RingEffectBitmap, L_TextureAlphaBlendBitmap

Topics:

Raster Image Functions: Filtering Images

 

Applying Artistic Effects

 

Detecting and Enhancing Edges and Lines

 

Raster Image Functions: Detecting and Enhancing Edges and Lines

Example

The following example applies the emboss mask over the bitmap:

 L_INT MaskConvolutionBitmapExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;   
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   nRet = L_MaskConvolutionBitmap(&LeadBitmap, 500, 45, 3, MSKC_EMBOSS);
   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;
}