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)

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

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle that references the bitmap to which to apply the effect.

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

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

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

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

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

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

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

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

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

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

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

Value Meaning
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

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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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

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