Uses a pseudo-random number generator in order to create a Perlin noise, and then procedurally transforms that noise into a texture.
#include "ltwrappr.h"
L_INT LBitmap::Perlin (uSeed, uFrequency, uIteration, uOpacity, crBClr, crFClr, nxCircle, nyCircle, nFreqLayout, nDenLayout, uFlags)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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. |
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. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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.
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.
Perlin Noise Function - Before
Perlin Noise Function - After
View additional platform support for this Perlin Noise function.
Win32, x64.
L_INT LBitmap__PerlinExample()
{
L_INT nRet;
/* 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;
nRet =LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), 0,ORDER_BGR);
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 =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) ;
if(nRet !=SUCCESS)
return nRet;
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms