Improve getPixel/setPixel behavior

This commit is contained in:
Joshua Granick
2015-07-23 08:09:18 -07:00
parent 4378412a54
commit abc83da97b

View File

@@ -605,7 +605,8 @@ class ImageDataUtil {
switch (format) {
case ARGB32: return pixel >> 8 & 0xFFFFFF;
case ARGB32: return (pixel:ARGB);
case BGRA32: return (pixel:BGRA);
default: return pixel;
}
@@ -976,11 +977,17 @@ class ImageDataUtil {
public static function setPixel (image:Image, x:Int, y:Int, color:Int, format:PixelFormat):Void {
if (format == RGBA32) color = color >> 8;
var pixel:RGBA;
switch (format) {
case ARGB32: pixel = (color:ARGB);
case BGRA32: pixel = (color:BGRA);
default: pixel = color;
}
var pixel:RGBA = color;
pixel.a = 0xFF;
pixel.writeUInt8 (image.buffer.data, (4 * (y + image.offsetY) * image.buffer.width + (x + image.offsetX) * 4), image.buffer.format, image.buffer.premultiplied);
image.dirty = true;