From abc83da97b966ae1721688576d78d08e854cae7f Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 23 Jul 2015 08:09:18 -0700 Subject: [PATCH] Improve getPixel/setPixel behavior --- lime/graphics/utils/ImageDataUtil.hx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lime/graphics/utils/ImageDataUtil.hx b/lime/graphics/utils/ImageDataUtil.hx index da114a52e..1d2de9616 100644 --- a/lime/graphics/utils/ImageDataUtil.hx +++ b/lime/graphics/utils/ImageDataUtil.hx @@ -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;