GNOME Bugzilla – Bug 673315
raw RGB565 bitmap loader is endian-specific
Last modified: 2012-09-26 21:18:10 UTC
A raw RGB565 image loaded on HP-UX/itanium may work correctly, but the same image loaded on Windows/itanium produces garbled results. Similarly with Linux/x86 vs Linux/PA-Risc. The problem appears to be in plug-ins/common/file-raw.c - when reading/writing 2byte ints, the current endianness must be taken into account. However, since the RGB565 raw loader means different things on different hardware, I propose we support both, naming one RGB565BE and the other RGB565LE.
Would you provide a patch for this?
I intend to, but am pretty busy right now. I'd also like to add some common YUV formats too,but again I haven't had time.
Created attachment 225041 [details] [review] Patch against 0ca03e88275 to fix RGB565 portability problems. This patch splits 'RGB565' support into two different modes, one to handle each possible endianness of RGB565. I made some test images here: https://github.com/rsaxvc/test-image-files
Created attachment 225042 [details] [review] Add support for BGR based 565 raw images
The second patch adds BGR565LE and BGR565BE support as well.
Thanks a lot :) raw seems to be turning into a swiss army knife. Can you adapt the patches to use the already existing G_BYTE_ORDER and GUINT16_SWAP_LE_BE() macros please? Raising priority because this is a straightforward enhancement with almost ready-to-apply patches.
I'll try to post new patches sometime this week.
Created attachment 225120 [details] [review] Patch against 0ca03e88275 to fix RGB565 portability problems, using G_ENDIAN stuff This combines the previous two patches and uses the existing glib framework to detect endianness at compile-time, as well as to swap the endianness on 16-bit pixels. This patch was tested on Linux 3.2.0, and tested against images located here: https://github.com/rsaxvc/test-image-files
Thanks for the update, pushed to master (not to 2.8 because it adds new features and translatable strings). Did some cosmetic cleanup, the patch used foo( bar ) instead of foo (bar). commit b88f1b04ddcc38a8454e10175177e00c307f97bb Author: Richard Allen <rsaxvc@gmail.com> Date: Sun Sep 23 21:02:40 2012 -0500 Bug 673315 - raw RGB565 bitmap loader is endian-specific Split raw RGB565 into RGB565LE/RGB565BE/BGR565LE/BGR565BE This change splits the raw file importing to handle the two different endiannesses natively. This fixes a bug where the same image would import different on different CPUs or even on different operating systems on the same CPU. This also adds the ability to directly open BRG565 files from the raw file import dialog. plug-ins/common/file-raw.c | 146 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 103 insertions(+), 43 deletions(-)