From 8f68604bcc0c5aec338220de37bc9eede4bed983 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 13 Oct 2008 21:17:27 +0000 Subject: [PATCH] libpipi: do not swap bytes in the GDI loader. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2945 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/codec/gdi.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pipi/codec/gdi.c b/pipi/codec/gdi.c index 652d6a4..f775c51 100644 --- a/pipi/codec/gdi.c +++ b/pipi/codec/gdi.c @@ -68,15 +68,8 @@ pipi_image_t *pipi_load_gdi(const char *name) return NULL; } - /* FIXME: get rid of this loop, maybe by using BITMAPV4HEADER above - * so that GDI reorders the pixels for us. */ - for(y = 0; y < img->h; y++) - for(x = 0; x < img->w; x++) - { - /* Swap B and R, don't touch G and A. */ - uint8_t tmp = data[0]; data[0] = data[2]; data[2] = tmp; - data += 4; - } + /* FIXME: do we need to swap bytes? Apparently Vista doesn't need it, + * but we'd need a more thorough test. */ img->codec_priv = NULL; @@ -133,9 +126,9 @@ int pipi_save_gdi(pipi_image_t *img, const char *name) for(x = 0; x < img->w; x++) { uint8_t tmp[3]; - tmp[0] = data[4 * (img->w * (img->h - 1 - y) + x) + 2]; + tmp[0] = data[4 * (img->w * (img->h - 1 - y) + x) + 0]; tmp[1] = data[4 * (img->w * (img->h - 1 - y) + x) + 1]; - tmp[2] = data[4 * (img->w * (img->h - 1 - y) + x) + 0]; + tmp[2] = data[4 * (img->w * (img->h - 1 - y) + x) + 2]; WriteFile(hfile, tmp, 3, &ret, NULL); } if(padding)