Copy link to clipboard
Copied
Hi,
I can't unserstand - how I can upload BitmapData.getPixels if uploadFromByteArray use BGRA colorspace and BitmapData.getPixels returns ARGB
What I should to do ?
Here is solution
var bm : BitmapData = new preview();
var outBm : BitmapData = new BitmapData(bm.width,bm.height,bm.transparent);
for ( var i : int = 0 ; i < bm.width; i ++ ) {
for ( var j : int = 0 ; j < bm.height; j ++ ) {
var BGR : uint = (bm.getPixel32(i,j) & 0x000000ff) << 16 | (bm.getPixel32(i,j) & 0x0000FF00) | (bm.getPixel32(i,j) & 0x00FF0000) >> 16;
outBm.setPixel32(i,j,BGR);
}
}
Copy link to clipboard
Copied
Try getPixel32 which returns ARGB. Here's the link:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html
That's just to BitmapData. You will find the method getPixel32 there.
Copy link to clipboard
Copied
Thanks, but this not that I'm looking for.
getPixels - return ByteArray of BitmapData.
And getPixel32 return single pixel. So I thing I need way to convert BitmapData bytearray from argb (rgb) to bgra (bgr)
Copy link to clipboard
Copied
Here is solution
var bm : BitmapData = new preview();
var outBm : BitmapData = new BitmapData(bm.width,bm.height,bm.transparent);
for ( var i : int = 0 ; i < bm.width; i ++ ) {
for ( var j : int = 0 ; j < bm.height; j ++ ) {
var BGR : uint = (bm.getPixel32(i,j) & 0x000000ff) << 16 | (bm.getPixel32(i,j) & 0x0000FF00) | (bm.getPixel32(i,j) & 0x00FF0000) >> 16;
outBm.setPixel32(i,j,BGR);
}
}