Skip to content

Commit

Permalink
2005-01-26 Geoff Norton <gnorton@customerdna.com>
Browse files Browse the repository at this point in the history
 	* configure.in: Add AC_C_BIGENDIAN check to define WORDS_BIGENDIAN where needed
        * src/bmpcodec.c: Swap from RGBA to ABGR on big endian systems.



svn path=/trunk/libgdiplus/; revision=39556
  • Loading branch information
Geoff Norton committed Jan 26, 2005
1 parent 1d02887 commit a4cc2fc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,3 +1,6 @@
2005-01-26 Geoff Norton <gnorton@customerdna.com>

* configure.in: Add AC_C_BIGENDIAN check to define WORDS_BIGENDIAN where needed

Tue Jan 25 11:34:41 CET 2005 Paolo Molaro <lupus@ximian.com>

Expand Down
2 changes: 2 additions & 0 deletions configure.in
Expand Up @@ -6,6 +6,8 @@ AM_INIT_AUTOMAKE(libgdiplus,1.1.3)
AM_MAINTAINER_MODE
AM_PROG_LIBTOOL

AC_C_BIGENDIAN

AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
AC_MSG_ERROR([You need to install pkg-config])
Expand Down
4 changes: 4 additions & 0 deletions src/ChangeLog
@@ -1,3 +1,7 @@
2005-01-26 Geoff Norton <gnorton@customerdna.com>

* bmpcodec.c: Swap from RGBA to ABGR on big endian systems.

2005-01-26 Peter Bartok <pbartok@novell.com>

* bmpcodec.c: Fixed R/B swap mistake
Expand Down
53 changes: 24 additions & 29 deletions src/bmpcodec.c
Expand Up @@ -140,6 +140,21 @@ gdip_load_bmp_image_from_stream_delegate (GetBytesDelegate getBytesFunc,
}

#define palette_lookup(x) img->image.palette->Entries[(x)]
#ifdef WORDS_BIGENDIAN
#define set_pixel_bgra(pixel,index,b,g,r,a) do {\
pixel[index+0] = a; \
pixel[index+1] = r; \
pixel[index+2] = g; \
pixel[index+3] = b; \
} while (0);
#else
#define set_pixel_bgra(pixel,index,b,g,r,a) do {\
pixel[index+0] = b; \
pixel[index+1] = g; \
pixel[index+2] = r; \
pixel[index+3] = a; \
} while (0);
#endif

GpStatus
gdip_read_bmp_image_from_file_stream (void *pointer, GpImage **image, bool useFile)
Expand Down Expand Up @@ -379,15 +394,9 @@ gdip_read_bmp_image_from_file_stream (void *pointer, GpImage **image, bool useFi
index = (line * img->data.Stride) + (c*8 + bit) * 4;

if ((data_read[c] & ((0x80 >> bit) & 0x1) ) == 0) {
pixels[index] = 0xff;
pixels[index + 1] = 0xff;
pixels[index + 2] = 0xff;
pixels[index + 3] = 0xff;
set_pixel_bgra(pixels, index, 0xff, 0xff, 0xff, 0xff);
} else {
pixels[index] = 0x0;
pixels[index + 1] = 0x0;
pixels[index + 2] = 0x0;
pixels[index + 3] = 0xff; // Alpha
set_pixel_bgra(pixels, index, 0x00, 0x00, 0x00, 0xff);
}
}
}
Expand All @@ -396,12 +405,9 @@ gdip_read_bmp_image_from_file_stream (void *pointer, GpImage **image, bool useFi
index = (line * img->data.Stride) + (c*8 + bit) * 4;

if ((data_read[c] & ((0x80 >> bit) & 0x1) ) == 0) {
pixels[index] = 0xff;
pixels[index + 1] = 0xff;
pixels[index + 2] = 0xff;
pixels[index + 3] = 0xff;
set_pixel_bgra(pixels, index, 0xff, 0xff, 0xff, 0xff);
} else {
pixels[index + 3] = 0xff; // Alpha
set_pixel_bgra(pixels, index, 0x00, 0x00, 0x00, 0xff);
}
}
break;
Expand All @@ -415,17 +421,11 @@ gdip_read_bmp_image_from_file_stream (void *pointer, GpImage **image, bool useFi

index = (line * img->data.Stride) + c*8;

pixels[index] = (pixel & 0xff0000) >> 16; // R
pixels[index + 1] = (pixel & 0xff00) >> 8; // G
pixels[index + 2] = pixel & 0xff; // B
pixels[index + 3] = 0xff; // Alpha
set_pixel_bgra(pixels, index, (pixel & 0xff0000) >> 16, (pixel & 0xff00) >> 8, pixel & 0xff, 0xff);

pixel = palette_lookup(data_read[c] & 0xf);

pixels[index + 4] = (pixel & 0xff0000) >> 16; // R
pixels[index + 5] = (pixel & 0xff00) >> 8; // G
pixels[index + 6] = pixel & 0xff; // B
pixels[index + 7] = 0xff; // Alpha
set_pixel_bgra(pixels, index+4, (pixel & 0xff0000) >> 16, (pixel & 0xff00) >> 8, pixel & 0xff, 0xff);
}
break;
}
Expand All @@ -438,10 +438,7 @@ gdip_read_bmp_image_from_file_stream (void *pointer, GpImage **image, bool useFi

index = (line * img->data.Stride) + c*4;

pixels[index] = (pixel & 0xff0000) >> 16; // R
pixels[index + 1] = (pixel & 0xff00) >> 8; // G
pixels[index + 2] = pixel & 0xff; // B
pixels[index + 3] = 0xff; // Alpha
set_pixel_bgra(pixels, index, (pixel & 0xff0000) >> 16, (pixel & 0xff00) >> 8, pixel & 0xff, 0xff);
}
break;
}
Expand All @@ -455,10 +452,8 @@ gdip_read_bmp_image_from_file_stream (void *pointer, GpImage **image, bool useFi

while (src < loop) {
index = (line * img->data.Stride);
pixels[index + dest++] = data_read[src + 0]; // R
pixels[index + dest++] = data_read[src + 1]; // G
pixels[index + dest++] = data_read[src + 2]; // B
pixels[index + dest++] = 0xff; // Alpha
set_pixel_bgra(pixels, index+dest, data_read[src+0], data_read[src+1], data_read[src+2], 0xff);
dest += 4;

src += 3;
}
Expand Down
5 changes: 0 additions & 5 deletions src/gdip.h
Expand Up @@ -37,13 +37,8 @@
#endif
#endif

#if HAVE_CAIRO_FT_FONT_LOCK_FACE
#define gdip_cairo_ft_font_lock_face(font) cairo_ft_font_lock_face(font)
#define gdip_cairo_ft_font_unlock_face(font) cairo_ft_font_unlock_face(font)
#else
#define gdip_cairo_ft_font_lock_face(font) cairo_ft_font_face(font)
#define gdip_cairo_ft_font_unlock_face(font)
#endif


#ifdef CAIRO_HAS_XLIB_SURFACE
Expand Down

0 comments on commit a4cc2fc

Please sign in to comment.