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

Texture.uploadFromByteArray() and BitmapData ARGB

Advocate ,
May 02, 2012 May 02, 2012

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 ?

TOPICS
Development

Views

954

Translate

Translate

Report

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

}

}

Votes

Translate

Translate
LEGEND ,
May 03, 2012 May 03, 2012

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.

Votes

Translate

Translate

Report

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

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)

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

}

}

Votes

Translate

Translate

Report

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