CImage:Blend
The Blend method blends the pixel values with those of another image or with a value. The result replaces the current image. One application of this method is to "morph" one image into another or fade it to a constant value. To do this, use repeatedly in a loop to create intermediate images that increment the blend parameter fractionally beween 0 and 1. Adding two image and then dividing by 2.0 gives the same result as blending using a blending parameter of 0.5.
bSuccess = CImage:Blend( CImage2, nBlend )
bSuccess = CImage:Blend( value, nBlend )
where
CImage is another CImage to be blended.
value is a numeric value to blend, or a string that can be converted to a number.
nBlend is theblending parameter, the fractional "distance" to interpolate between values. See below.
bSuccess is the returned success code. On success it is true, otherwise false.
Each pixel value of the CImage is replaced by the result of an interpolation with another value. The value may be either the pixel at the same location in another image or a constant value. The valuenBlend measures the interpolation distance between the two images. For each image pixels, the result is as follows:
nBlend = 0 reproduces the present image exactly.
nBlend = 1.0 reproduces the other image exactly.
nBlend = 0.5 produces a result midway between the two images or between the image and value.
Values outside the range [0,1] are extrapolated by, effectively, removing one pixel value from the other.
The following script loads two images from files sPath1 and sPath2 and blends them equally usingnBlend = 0.5:
|
-- create a new CImage |
|
-- create a new CImage |
|
-- load the first image from a file named sPath1 |
|
-- load the second image from a file named sPath2 |
|
-- perform the operation on image I |