LBitmap::Perlin
#include "ltwrappr.h"
L_INT LBitmap::Perlin (uSeed, uFrequency, uIteration, uOpacity, crBClr, crFClr, nxCircle, nyCircle, nFreqLayout, nDenLayout, uFlags)
L_UINT32 uSeed; |
/* seed value for the randomization process */ |
L_UINT uFrequency; |
/* x and y axis frequency */ |
L_UINT uIteration; |
/* number of iterations */ |
L_UINT uOpacity; |
/* percent combination */ |
COLORREF crBClr; |
/* background color */ |
COLORREF crFClr; |
/* 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. This function is available in the Raster Pro and above toolkits.
Parameter |
Description | |
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 axes. Possible values range from 0 to 16. No noise is created if the value is 0. Increasing this value increases the noise. | |
uIteration |
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 flags are set in the uFlags parameter. A value of 0 indicates that no noise is being used and a value of 100 represents a mix of noise and image. | |
crBClr |
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. | |
crFClr |
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 in the uFlags parameter. | |
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 in the uFlags parameter. | |
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 flags are set to uFlags parameter. Possible values are range from 0 through 100. Increasing this value increases 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 indicate 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 indicate 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 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.
This function is similar to the LBitmap::Clouds 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 LBitmap::AddNoise 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 only in the Document/Medical toolkits.
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
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.
Required DLLs and Libraries
LTIMG For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Example
/* The following example loads a bitmap and adds Perlin noise to it: */
/* Load the bitmap, keeping the bits per pixel of the file */
LBitmap LeadBitmap;
LeadBitmap.Load(TEXT("C:\\IMAGE4.CMP"), 0,ORDER_BGR);
/* 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*/
LeadBitmap.Perlin( 0, 10, 8, 50, RGB (0, 0, 0), RGB (255, 0, 0), (L_INT) LeadBitmap.GetWidth() / 2, (L_INT) LeadBitmap.GetHeight() / 2, 4, 20, PRL_PURE |PRL_CIRCLE) ;