View Full Version : Read raw RGBA data from PNG file
yossim
10-15-2007, 10:58 AM
I need to get the exact RGBA values from a PNG file I have in the library.
When using the BitmapData class, I get premultiplied values.
It changes the original data by multipling the RGB with the Alpha channel.
How can I get the original data from the PNG?
Thanks.
panel
10-15-2007, 12:28 PM
you should use
bitmapData.getPixel32()
example from help
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(80, 40, true, 0xFF44AACC);
var pixelValue:uint = bmd.getPixel32(1, 1);
var alphaValue:uint = pixelValue >> 24 & 0xFF;
var red:uint = pixelValue >> 16 & 0xFF;
var green:uint = pixelValue >> 8 & 0xFF;
var blue:uint = pixelValue & 0xFF;
trace(alphaValue.toString(16)); // ff
trace(red.toString(16)); // 44
trace(green.toString(16)); // aa
trace(blue.toString(16)); // cc
yossim
10-15-2007, 01:01 PM
getPixel32 does not feet my needs, since there is a lose of information.
As I mentioned in the question (and also described in the help)
this function gives the premultiplied values.
It means that if the Alpha value is not FF, the RGB values I get are already multiplied with the Alpha.
I need the original RGBA values.
senocular
10-15-2007, 01:42 PM
BitmapData is all you have
yossim
10-17-2007, 09:00 AM
I'll probably have to use only the RGB channels.
Thanks anyway
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.