AGK for Pascal
TAgkImage.Create Constructor (TAgkObject, String, String, TAgkColorChannel, Boolean)

Loads an image from a file containing the image data and a file containing a transparency mask.

constructor Create(const Owner: TAgkObject; const ImageFilename: String; const MaskFilename: String; const MaskChannel: TAgkColorChannel; const GenerateMipmaps: Boolean = False); overload;
const Owner: TAgkObject 
the owner of the new image (eg. a TAgkScene object). 
const ImageFilename: String 
the filename of the image to load. 
const MaskFilename: String 
the name of the file containing the transparency mask. 
const MaskChannel: TAgkColorChannel 
the channel in the mask file to use for transparency. 
const GenerateMipmaps: Boolean = False 
(optional) Set to True to automatically generate mipmaps for this image (default False). 

This constructor is useful for large images with transparency. You could create a single PNG file for the image, but since PNG doesn't compress very well, you end up with a large image file. 

With this constructor, you can put the actual image in a JPEG file and compress is to your needs. Then you can have a separate PNG file with just the alpha information, which usually compresses very well. The size of the two files combined is usually much smaller than a single PNG file with transparency. 

If the PNG file contains an actual transparency channel, then you can set MaskChannel to ccAlpha. However, sometimes it is more efficient to create a grayscale PNG file without alpha channel, and just use the grayscale image as the mask (where black is fully transparent and white is fully opaque). In that case, you can set MaskChannel to ccRed, ccGreen or ccBlue (doesn't matter which).

Copyright (c) 2012. All rights reserved.