Browse Source

imlib2: Fix RGBA order in loader and use imlib_image_get_data_for_reading_only()

undefined
Jean-Yves Lamoureux Sam Hocevar <sam@hocevar.net> 10 years ago
parent
commit
cf72e40d62
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      src/image/codec/imlib2-image.cpp

+ 5
- 0
src/image/codec/imlib2-image.cpp View File

@@ -68,6 +68,11 @@ bool Imlib2ImageCodec::Load(Image *image, char const *path)


image->SetSize(size); image->SetSize(size);
u8vec4 *data = image->Lock<PixelFormat::RGBA_8>(); u8vec4 *data = image->Lock<PixelFormat::RGBA_8>();
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); memcpy(data, imlib_image_get_data(), 4 * size.x * size.y);
image->Unlock(data); image->Unlock(data);




Loading…
Cancel
Save