From efc92cffc0459f6a45da95b7c881467ec684f9f9 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Fri, 24 Jul 2015 20:18:19 -0700 Subject: [PATCH] Patch image.encode --- lime/graphics/format/BMP.hx | 10 ++++++++++ lime/graphics/format/JPEG.hx | 10 ++++++++++ lime/graphics/format/PNG.hx | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/lime/graphics/format/BMP.hx b/lime/graphics/format/BMP.hx index ffad8c901..c6cb1586d 100644 --- a/lime/graphics/format/BMP.hx +++ b/lime/graphics/format/BMP.hx @@ -11,6 +11,16 @@ class BMP { public static function encode (image:Image, type:BMPType = null):ByteArray { + if (image.premultiplied || image.format != RGBA32) { + + // TODO: Handle encode from different formats + + image = image.clone (); + image.premultiplied = false; + image.format = RGBA32; + + } + if (type == null) { type = RGB; diff --git a/lime/graphics/format/JPEG.hx b/lime/graphics/format/JPEG.hx index 7ffc66756..d4957d909 100644 --- a/lime/graphics/format/JPEG.hx +++ b/lime/graphics/format/JPEG.hx @@ -55,6 +55,16 @@ class JPEG { public static function encode (image:Image, quality:Int):ByteArray { + if (image.premultiplied || image.format != RGBA32) { + + // TODO: Handle encode from different formats + + image = image.clone (); + image.premultiplied = false; + image.format = RGBA32; + + } + #if java #elseif (sys && (!disable_cffi || !format)) diff --git a/lime/graphics/format/PNG.hx b/lime/graphics/format/PNG.hx index 341820da6..9488a8302 100644 --- a/lime/graphics/format/PNG.hx +++ b/lime/graphics/format/PNG.hx @@ -62,6 +62,16 @@ class PNG { public static function encode (image:Image):ByteArray { + if (image.premultiplied || image.format != RGBA32) { + + // TODO: Handle encode from different formats + + image = image.clone (); + image.premultiplied = false; + image.format = RGBA32; + + } + #if java #elseif (sys && (!disable_cffi || !format))