L_PerlinBitmap

#include "l_bitmap.h"

L_LTIMGSFX_API L_INT L_PerlinBitmap(pBitmap, uSeed, uFrequency, uDensity, uOpacity, cBackColor, Perlin, nxCircle, nyCircle, nFreqLayout, nDenLayout, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

L_UINT uSeed;

seed value for the randomization process

L_UINT uFrequency;

x and y axis frequency

L_UINT uDensity;

number of iterations

L_UINT uOpacity;

percent combination

COLORREF cBackColor;

background color

COLORREF Perlin;

foreground color

L_INT nxCircle;

x coordinate of the center point of the layout circles

L_INT nyCircle;

y coordinate of the center point of the layout circles

L_INT nFreqLayout;

layout frequency

L_INT nDenLayout;

layout density

L_UINT uFlags;

flags

Uses a pseudo-random number generator in order to create a Perlin noise, and then procedurally transforms that noise into a texture.

Parameter Description
pBitmap Pointer to the bitmap handle that references the bitmap to which to apply the effect.
uSeed Value that represents the initial seeding value for the pseudo-randomization process. Use 0 for automatic seeding. If other parameters are kept the same, each seed value always produces the same effect. Each seed value produces an effect different from all of the other seed values.
uFrequency Value that represents the frequency component for both the x and y axis. Possible values range from 0 to 16. No noise is created if the value is 0. Increasing this value increases the noise.
uDensity Value that represents the number of iterations that will be calculated. Possible values range from 0 to 8. No noise is created if the value is 0. Increasing this value increases the detail in the noise, as well as computation time.
uOpacity Value that represents the percentage to be used when combining the original bitmap with the noise. Possible values range from 0 through 100. This parameter is used if the PRL_COMBINE or PRL_DIFFERENCE flag is set. A value of 0 indicates that no noise is being used and a value of 100 represents a mix of noise and image.
cBackColor A COLORREF value that represents the background color. You can specify a COLORREF value, such as the return value of the Windows RGB macro, or you can use the PALETTEINDEX macro to specify a palette color.
Perlin A COLORREF value that represents the foreground color. You can specify a COLORREF value, such as the return value of the Windows RGB macro, or you can use the PALETTEINDEX macro to specify a palette color.
nxCircle The x coordinate, in pixels and in bitmap coordinates, for the center point of the concentric circles. Possible values range from 0 to the width of the bitmap. This parameter is only used if the PRL_CIRCLE flag is set.
nyCircle The y coordinate, in pixels and in bitmap coordinates, for the center point of the concentric circles. Possible values range from 0 to the height of the bitmap. This parameter is only used if the PRL_CIRCLE flag is set.
nFreqLayout Value used to control the frequency of the circles or lines to be created for the noise bitmap. This parameter is used if the PRL_CIRCLE or PRL_LINE flag is set. Possible values range from 0 through 100. Increase this value to increase the number of circles or lines drawn.
nDenLayout Value that represents the density of the layout for the produced noise. Possible values range from 0 through 100. When using a low nDenLayout value the noise will appear with light color.
uFlags Flags that specify how to apply the effect, and which layout pattern to use for the noise. You can use a bit wise OR (|) to specify one flag from each group.

The following flags specify how to apply the effect:

  Value Meaning
  PRL_PURE [0x00] Produce noise as a new bitmap.
  PRL_COMBINE [0x01] Combine the noise and the bitmap pixels using the uOpacity value.
  PRL_DIFFERENCE [0x02] Apply the difference between the noise and the bitmap pixels.
  The following flags indicate which layout pattern to use for the noise:
  PRL_CIRCLE [0x00] Lay out the noise in concentric circles. Set the center for the circle using nxCircle and nyCircle.
  PRL_LINE [0x10] Lay out the noise in lines at a 45 degree angle.
  PRL_RANDOM [0x20] Lay out the noise randomly.

Returns

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 uses a pseudo-random number generator in order to create a Perlin noise, and then procedurally transforms that noise into a texture. Depending on the flags that are set, the texture can be saved as a bitmap by itself, or the texture can be combined with another bitmap. For more information, refer to Using the L_PerlinBitmap function.

This function is similar to the L_CloudsBitmap function in that they both use Perlin equations to generate pseudo-random noise, but each function applies different equations to the noise to produce the texture.

Use the L_AddBitmapNoise function in order to add random noise to a bitmap.

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 signed data images. It returns the error

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

LTIMGSFX

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_AddBitmapNoise, L_SharpenBitmap, L_PosterizeBitmap, L_MosaicBitmap, L_EmbossBitmap, L_AverageFilterBitmap, L_MedianFilterBitmap, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_OilifyBitmap, L_SolarizeBitmap, L_DlgAddNoise, 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, L_AddBitmapNoise

Topics:

Raster Image Functions: Filtering Images

 

Applying Artistic Effects

 

Using the L_PerlinBitmap function

Example

The following example loads a bitmap and adds Perlin noise to it:

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT PerlinBitmapExample(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("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* Add noise to the bitmap with automatic seeding, and using a frequency value of 10, */ 
   /*  a number of iterations value of 8, a percent of combination value of 50, */ 
   /*a black background, a red foreground, */ 
   /*with the center point of the noise circles in the middle of the bitmap, */ 
   /*a layout frequency value of 4, a noise layout density value of 20 */ 
   /*and lay out the noise in circles in a new bitmap*/ 
   nRet = L_PerlinBitmap(&LeadBitmap,  0, 10, 8, 50,  RGB (0, 0, 0), RGB (255, 0, 0), (L_INT) LeadBitmap.Width / 2, (L_INT) LeadBitmap.Height / 2, 4, 20, PRL_PURE |PRL_CIRCLE); 
   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 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