[C#]
using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/transparent.png"))) {
bm.PixelFormat = new PixelFormat(bm.PixelFormat, ColorChannel.Alpha, false);
Effects.AdjustColors<object>(bm, null, (color, context) => {
color.R = color.A;
color.G = color.A;
color.B = color.A;
color.A = 0xFF;
return color;
});
bm.Save(Server.MapPath("IG8_Effect_PixelFormat.jpg"));
}
The above reads a PNG with transparency and extracts the alpha
channel as a gray intensity map. The input and output files are
shown below.
transparent.png
IG8_Effect_PixelFormat.jpg
|