Improve getPixel/setPixel behavior
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user