Language Reference Guide : System Classes : BitmapObject Class : ReplaceTransparency Method
 
Share this page          
ReplaceTransparency Method
The ReplaceTransparency method changes the color of the transparency layer of a image.
This method has the following syntax:
integer = BitmapObject.ReplaceTransparency(replacementcolor=integer[, alphavalue=integer]);
This method has the following parameters:
replacementcolor
Specifies the new RGB value of the replaced color
alphavalue
(Optional) Specifies the alpha value.
Valid values: 0–255
Default: 0
If the method is successful, it returns ER_OK; otherwise, it returns ER_FAIL. Descriptions of system constant values and their numeric equivalents are listed in Error Codes.
This method replaces the pixel color value of the bitmap object with the given alpha value. This applies only to 32-bit images with an RGBA channel. The alpha value must be between 0–255.
alphavalue = 0 = transparent image pixel
alphavalue = 255 = non-transparent image pixel
The default alpha value is 0, which replaces the pixel color of the transparent layer of an image.
This method will make no changes to other image pixels unless the matching alpha value is found. It also does not change any pixel’s alpha value.
If the BitmapObject has no 32-bit image (such as a PNG image), it will not change the colors of any pixel.
If the input alpha value is not in the range of 0–255, it will not change color of any pixel of BitmapObject.
Example:
sigPNG = BitmapObject;
sigJPEG = BitmapObject;
...
sigPNG.FileHandle = 'c:\temp\TestPNG.png';
SigFileName = 'c:\temp\out\TestJPEG.jpg';
// Now change the transparent image pixel to white color and save it as JPEG
sigPNG.ReplaceTransparency(replacementcolor=RGB(red=255, green=255, blue=255)/*,alphavalue=0*/);
sigPNG.WriteToFile(filename = SigFileName, format = BF_JPEG);
sigJPEG.FileHandle = SigFileName;