From cf72e40d62150add3f50a674e40b9fe2be8878c5 Mon Sep 17 00:00:00 2001 From: Jean-Yves Lamoureux Date: Fri, 2 Jan 2015 13:12:14 +0000 Subject: [PATCH] imlib2: Fix RGBA order in loader and use imlib_image_get_data_for_reading_only() --- src/image/codec/imlib2-image.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/image/codec/imlib2-image.cpp b/src/image/codec/imlib2-image.cpp index 8a0201db..b5c5ef20 100644 --- a/src/image/codec/imlib2-image.cpp +++ b/src/image/codec/imlib2-image.cpp @@ -68,6 +68,11 @@ bool Imlib2ImageCodec::Load(Image *image, char const *path) image->SetSize(size); u8vec4 *data = image->Lock(); + uint8_t *orig = (uint8_t*)imlib_image_get_data_for_reading_only(); + for(int i = 0; i < size.x*size.y; i++) { + data[i] = ((u8vec4 *)&orig[i * 4])->bgra; + } + memcpy(data, imlib_image_get_data(), 4 * size.x * size.y); image->Unlock(data);