Copy of Bitmap data is incorrect color?

162 views Asked by At

I'm loading an image into my application and then converting that image to base64 data and then displaying it again (on an HTML page). But when I do that the colors are different! I'm using getPixel32 to grab the image data. I read somewhere that Flash uses precomputed values and that is the reason. I vaguely understood it. Can someone explain or link to an article explaining what is going on and how to fix it?

Snippet of code:

byteArray = bitmapData.getPixels(new Rectangle(0, 0, bitmapData.width, bitmapData.height));

Also, is it possible it's lost it's color profile?

UPDATE
I'm including the code I use to take a screen shot and convert it to base 64 data. http://pastebin.com/Q7MiWg9u

1

There are 1 answers

2
Andrey Popov On

That's a very nice question! I'm posting this as an answer first because it's too long for a comment and second, because this article will at least help you understand what's the problem: http://www.quasimondo.com/archives/000665.php

Everything is because of the pre-multiplied alpha and the way Flash works with it.

I'm going to make a few small tests to see if you can actually fix this using getPixel32 and setPixel32, where you can use the unmultipleid values and calculate what's the actual ones that you need to set.