Created
January 31, 2012 04:37
-
-
Save alecmce/1708844 to your computer and use it in GitHub Desktop.
Neko BitmapData Bongo Madness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// due to Neko's 31 bit integers and other nonsense, when you set a bitmap data's alpha value | |
// through Neko and then read it back out, the number ranges from -127 to 127 rather than from | |
// 0 to 255. Bongo madness. To unbongo, convert as follows: | |
var bitmapData = new BitmapData(1, 1, true, {rgb:0, a:0}); | |
for (i in 0...256) | |
{ | |
bitmapData.setPixel32(0, 0, {rgb:0xFFFFFF, a:i}); | |
var alpha = bitmapData.getPixel32(0, 0).a; | |
var converted = alpha < 0 ? 255 + alpha : alpha; | |
trace(i + ": " + alpha + " -> " + converted); | |
} | |
// i == converted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment