Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Texture.uploadFromByteArray() and BitmapData ARGB

Advocate ,
May 02, 2012 May 02, 2012

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 ?

TOPICS
Development
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , May 21, 2012 May 21, 2012

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);

}

}

Translate
LEGEND ,
May 03, 2012 May 03, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 03, 2012 May 03, 2012

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 21, 2012 May 21, 2012
LATEST

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);

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines