Permalink
Browse files

2007-06-21 Sebastien Pouliot <sebastien@ximian.com>

	* bitmap.c, bmpcodec.c, icocodec.c, imageattributes.c, image.c,
	jpegcodec.c, pngcodec.c, tiffcodec.c, gdipenums.h: Fix PixelFormat*Rgb
	(and Argb) to PixelFormat*RGB (and ARGB) to match MS GDI+ definitions.
	Patch by Yves Bastide.


svn path=/trunk/libgdiplus/; revision=80442
  • Loading branch information...
1 parent 4dd0ccd commit 7b6ebebbd558ba83d4d01fc0a6383e295180824c Sebastien Pouliot committed Jun 21, 2007
Showing with 122 additions and 115 deletions.
  1. +7 −0 src/ChangeLog
  2. +38 −38 src/bitmap.c
  3. +12 −12 src/bmpcodec.c
  4. +10 −10 src/gdipenums.h
  5. +1 −1 src/icocodec.c
  6. +27 −27 src/image.c
  7. +1 −1 src/imageattributes.c
  8. +7 −7 src/jpegcodec.c
  9. +16 −16 src/pngcodec.c
  10. +3 −3 src/tiffcodec.c
View
@@ -1,3 +1,10 @@
+2007-06-21 Sebastien Pouliot <sebastien@ximian.com>
+
+ * bitmap.c, bmpcodec.c, icocodec.c, imageattributes.c, image.c,
+ jpegcodec.c, pngcodec.c, tiffcodec.c, gdipenums.h: Fix PixelFormat*Rgb
+ (and Argb) to PixelFormat*RGB (and ARGB) to match MS GDI+ definitions.
+ Patch by Yves Bastide.
+
2007-06-05 Sebastien Pouliot <sebastien@ximian.com>
* emfcodec.c, metafile-private.h, wmfcodec.c, wmfcodec.h: ++ is unsafe
View
@@ -75,10 +75,10 @@ gdip_is_a_supported_pixelformat (PixelFormat fmt)
case PixelFormat1bppIndexed:
case PixelFormat4bppIndexed:
case PixelFormat8bppIndexed:
- case PixelFormat24bppRgb:
- case PixelFormat32bppArgb:
- case PixelFormat32bppPArgb:
- case PixelFormat32bppRgb:
+ case PixelFormat24bppRGB:
+ case PixelFormat32bppARGB:
+ case PixelFormat32bppPARGB:
+ case PixelFormat32bppRGB:
return TRUE;
default:
return FALSE;
@@ -775,24 +775,24 @@ GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format
}
switch (format) {
- case PixelFormat24bppRgb: {
+ case PixelFormat24bppRGB: {
cairo_format = CAIRO_FORMAT_RGB24;
break;
}
- case PixelFormat32bppArgb:
- case PixelFormat32bppPArgb:
+ case PixelFormat32bppARGB:
+ case PixelFormat32bppPARGB:
flags = ImageFlagsHasAlpha;
/* fall through */
- case PixelFormat32bppRgb:
+ case PixelFormat32bppRGB:
cairo_format = CAIRO_FORMAT_ARGB32;
break;
- case PixelFormat16bppRgb555:
- case PixelFormat16bppRgb565:
+ case PixelFormat16bppRGB555:
+ case PixelFormat16bppRGB565:
/* fake them as 32bpp RGB as Cairo deprecated CAIRO_FORMAT_RGB16_565 support */
/* why 32bpp ? because that's the result of MS GDI+ when loading them, even if the bitmap is empty */
- format = PixelFormat32bppRgb;
+ format = PixelFormat32bppRGB;
stride *= 2;
cairo_format = CAIRO_FORMAT_ARGB32;
break;
@@ -868,7 +868,7 @@ GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format
memset (scan0, 0, stride * height);
} else {
/* Since the pixel format is not an alpha pixel format (i.e., it is
- * either PixelFormat24bppRgb or PixelFormat32bppRgb), the image should be
+ * either PixelFormat24bppRGB or PixelFormat32bppRGB), the image should be
* initially black, not initially transparent. Thus, we need to set
* the alpha channel, which the user code doesn't think exists but
* Cairo is still paying attention to, to 0xFF.
@@ -982,7 +982,7 @@ GdipCreateBitmapFromGraphics (int width, int height, GpGraphics *graphics, GpBit
bitmap_data->width = width;
bitmap_data->height = height;
bitmap_data->stride = stride;
- bitmap_data->pixel_format = PixelFormat32bppArgb;
+ bitmap_data->pixel_format = PixelFormat32bppARGB;
bitmap_data->reserved = GBD_OWN_SCAN0;
bitmap_data->scan0 = GdipAlloc(stride * height);
if (bitmap_data->scan0 == NULL) {
@@ -1303,7 +1303,7 @@ gdip_is_pixel_format_conversion_valid (PixelFormat src, PixelFormat dest)
}
#if FALSE
-/* PixelFormat24bppRgb is internally stored by Cairo as a four bytes. Convert it to 3-byte (RGB) */
+/* PixelFormat24bppRGB is internally stored by Cairo as a four bytes. Convert it to 3-byte (RGB) */
int
gdip_from_ARGB_to_RGB (BYTE *src, int width, int height, int stride, BYTE **dest, int* dest_stride)
{
@@ -1339,7 +1339,7 @@ gdip_from_ARGB_to_RGB (BYTE *src, int width, int height, int stride, BYTE **dest
}
-/* PixelFormat24bppRgb is internally stored by Cairo as a three bytes. Convert it to 4-byte (ARGB) */
+/* PixelFormat24bppRGB is internally stored by Cairo as a three bytes. Convert it to 4-byte (ARGB) */
int
gdip_from_RGB_to_ARGB (BYTE *src, int width, int height, int stride, BYTE **dest, int* dest_stride)
{
@@ -1424,15 +1424,15 @@ gdip_init_pixel_stream (StreamingState *state, BitmapData *data, int x, int y, i
state->pixels_per_byte = 1;
state->scan += x; /* x * 8 / 8 */
break;
- case PixelFormat24bppRgb:
+ case PixelFormat24bppRGB:
/* GDI+ use 3 bytes for 24 bpp while Cairo use 4 bytes */
if (data->reserved & GBD_TRUE24BPP) {
state->pixels_per_byte = -3;
state->scan += ((x * 3) >> 3); /* x * 3 / 8 */
break;
}
/* else continue (don't break) */
- case PixelFormat32bppRgb:
+ case PixelFormat32bppRGB:
default:
/* indicate full RGB processing */
state->pixels_per_byte = -(gdip_get_pixel_format_bpp (data->pixel_format) >> 3);
@@ -1678,9 +1678,9 @@ gdip_pixel_stream_set_next (StreamingState *state, unsigned int pixel_value)
state->scan [0] = (pixel_value >> 24);
state->scan [1] = (pixel_value >> 16);
state->scan [2] = (pixel_value >> 8);
- state->scan [3] = (state->data->pixel_format == PixelFormat32bppRgb) ? 0xFF : pixel_value;
+ state->scan [3] = (state->data->pixel_format == PixelFormat32bppRGB) ? 0xFF : pixel_value;
#else
- if (state->data->pixel_format == PixelFormat32bppRgb)
+ if (state->data->pixel_format == PixelFormat32bppRGB)
pixel_value |= 0xFF000000;
*(unsigned int *)state->scan = pixel_value;
#endif
@@ -1797,9 +1797,9 @@ static BOOL
gdip_is_a_32bit_pixelformat (PixelFormat format)
{
switch (format) {
- case PixelFormat32bppRgb:
- case PixelFormat32bppArgb:
- case PixelFormat32bppPArgb: /* all of these use CAIRO_FORMAT_ARGB, which is 4 bytes wide */
+ case PixelFormat32bppRGB:
+ case PixelFormat32bppARGB:
+ case PixelFormat32bppPARGB: /* all of these use CAIRO_FORMAT_ARGB, which is 4 bytes wide */
return TRUE;
default:
return FALSE;
@@ -1856,7 +1856,7 @@ gdip_make_alpha_opaque (BitmapData *data)
int f;
/* sanity check; make sure we aren't mangling any image data */
- if ((data->pixel_format != PixelFormat32bppArgb) && (data->pixel_format != PixelFormat32bppRgb)) {
+ if ((data->pixel_format != PixelFormat32bppARGB) && (data->pixel_format != PixelFormat32bppRGB)) {
return;
}
@@ -1931,7 +1931,7 @@ GdipBitmapLockBits (GpBitmap *bitmap, GDIPCONST Rect *srcRect, UINT flags, Pixel
root_data->reserved |= GBD_LOCKED;
switch (format) {
- case PixelFormat24bppRgb:
+ case PixelFormat24bppRGB:
/* workaround a hack we have (because Cairo use 32bits in this case) */
dest_pixel_format_bpp = 24;
locked_data->reserved |= GBD_TRUE24BPP;
@@ -2049,12 +2049,12 @@ GdipBitmapSetPixel (GpBitmap *bitmap, int x, int y, ARGB color)
v = (BYTE*)(data->scan0) + y * data->stride;
switch (data->pixel_format) {
- case PixelFormat24bppRgb:
- case PixelFormat32bppRgb:
+ case PixelFormat24bppRGB:
+ case PixelFormat32bppRGB:
color |= 0xFF000000; /* force the alpha for Cairo */
/* fall through */
- case PixelFormat32bppArgb:
- case PixelFormat32bppPArgb: {
+ case PixelFormat32bppARGB:
+ case PixelFormat32bppPARGB: {
ARGB *scan = (ARGB *)v;
scan[x] = color;
break;
@@ -2111,10 +2111,10 @@ GdipBitmapGetPixel (GpBitmap *bitmap, int x, int y, ARGB *color)
switch (data->pixel_format) {
case PixelFormat16bppGrayScale:
return InvalidParameter;
- case PixelFormat24bppRgb:
- case PixelFormat32bppArgb:
- case PixelFormat32bppPArgb:
- case PixelFormat32bppRgb: {
+ case PixelFormat24bppRGB:
+ case PixelFormat32bppARGB:
+ case PixelFormat32bppPARGB:
+ case PixelFormat32bppRGB: {
ARGB *scan = (ARGB *)v;
*color = scan[x];
break;
@@ -2151,7 +2151,7 @@ gdip_bitmap_ensure_surface (GpBitmap *bitmap)
if ((bitmap->surface == NULL) && (data != NULL) && (data->scan0 != NULL)) {
switch (data->pixel_format) {
- case PixelFormat24bppRgb: {
+ case PixelFormat24bppRGB: {
bitmap->surface = cairo_image_surface_create_for_data(
(BYTE*)data->scan0,
CAIRO_FORMAT_RGB24,
@@ -2161,9 +2161,9 @@ gdip_bitmap_ensure_surface (GpBitmap *bitmap)
break;
}
- case PixelFormat32bppArgb:
- case PixelFormat32bppRgb:
- case PixelFormat32bppPArgb: {
+ case PixelFormat32bppARGB:
+ case PixelFormat32bppRGB:
+ case PixelFormat32bppPARGB: {
bitmap->surface = cairo_image_surface_create_for_data(
(BYTE*)data->scan0,
CAIRO_FORMAT_ARGB32,
@@ -2240,10 +2240,10 @@ gdip_convert_indexed_to_rgb (GpBitmap *indexed_bmp)
}
if ((palette->Flags & PaletteFlagsHasAlpha) == 0) {
- format = PixelFormat32bppRgb;
+ format = PixelFormat32bppRGB;
set_pixel_bgra (&force_alpha, 0, 0, 0, 0, 0xFF); /* full alpha bits set */
} else {
- format = PixelFormat32bppArgb;
+ format = PixelFormat32bppARGB;
force_alpha = 0;
}
View
@@ -95,19 +95,19 @@ gdip_get_bmp_pixelformat (BITMAPINFOHEADER *bih, PixelFormat *dest)
if (bitCount != 16)
return InvalidParameter;
/* note: incomplete at this stage */
- *dest = PixelFormat16bppRgb565;
+ *dest = PixelFormat16bppRGB565;
break;
default:
switch (bitCount) {
case 32:
- *dest = PixelFormat32bppRgb;
+ *dest = PixelFormat32bppRGB;
break;
case 24:
- *dest = PixelFormat24bppRgb;
+ *dest = PixelFormat24bppRGB;
break;
case 16:
/* MS produce such files (i.e. bad header) for storing ImageList bitmaps, see bug #80797 */
- *dest = PixelFormat16bppRgb565;
+ *dest = PixelFormat16bppRGB565;
break;
case 8:
*dest = PixelFormat8bppIndexed;
@@ -138,7 +138,7 @@ gdip_bitmap_fill_info_header (GpBitmap *bitmap, PBITMAPINFOHEADER bmi)
bmi->biWidth = GULONG_FROM_LE (bitmap->active_bitmap->width);
bmi->biHeight = GULONG_FROM_LE (bitmap->active_bitmap->height);
bmi->biPlanes = GUINT16_FROM_LE (1);
- if (format != PixelFormat24bppRgb)
+ if (format != PixelFormat24bppRGB)
bmi->biBitCount = GUINT16_FROM_LE (gdip_get_pixel_format_bpp (bitmap->active_bitmap->pixel_format));
else
bmi->biBitCount = GUINT16_FROM_LE (24);
@@ -151,7 +151,7 @@ gdip_bitmap_fill_info_header (GpBitmap *bitmap, PBITMAPINFOHEADER bmi)
bmi->biWidth = bitmap->active_bitmap->width;
bmi->biHeight = bitmap->active_bitmap->height;
bmi->biPlanes = 1;
- if (format != PixelFormat24bppRgb)
+ if (format != PixelFormat24bppRGB)
bmi->biBitCount = gdip_get_pixel_format_bpp (bitmap->active_bitmap->pixel_format);
else
bmi->biBitCount = 24;
@@ -808,7 +808,7 @@ gdip_read_bmp_image (void *pointer, GpImage **image, ImageSource source)
}
/* for 16bbp images we need to be more precise */
- if (format == PixelFormat16bppRgb565) {
+ if (format == PixelFormat16bppRGB565) {
/* check if we're dealing with a BITMAPV4HEADER (or later) structure */
if (bmi.biSize >= sizeof (BITMAPV4HEADER)) {
/* the new structure contains the ARGB masks */
@@ -848,7 +848,7 @@ gdip_read_bmp_image (void *pointer, GpImage **image, ImageSource source)
/* note: CAIRO_FORMAT_RGB16_565 is deprecated so we're promoting the bitmap to 32RGB */
/* why 32bpp when 24 would be enough ? because MS GDI+ loads them as such, but can't display them (empty) */
- format = PixelFormat32bppRgb;
+ format = PixelFormat32bppRGB;
/* 16bbp bitmap don't seems reversed like their height indicates */
upsidedown = FALSE;
}
@@ -870,12 +870,12 @@ gdip_read_bmp_image (void *pointer, GpImage **image, ImageSource source)
case PixelFormat8bppIndexed:
result->active_bitmap->stride = result->active_bitmap->width;
break;
- case PixelFormat24bppRgb:
+ case PixelFormat24bppRGB:
result->active_bitmap->stride = result->active_bitmap->width * 4;
break;
default:
/* For other types, we assume 32 bit and translate into 32 bit from source format */
- result->active_bitmap->pixel_format = PixelFormat32bppRgb;
+ result->active_bitmap->pixel_format = PixelFormat32bppRGB;
result->active_bitmap->stride = result->active_bitmap->width * 4;
break;
}
@@ -1181,7 +1181,7 @@ gdip_save_bmp_image_to_file_stream (void *pointer, GpImage *image, BOOL useFile)
BYTE *scan0;
activebmp = image->active_bitmap;
- if (activebmp->pixel_format != PixelFormat24bppRgb) {
+ if (activebmp->pixel_format != PixelFormat24bppRGB) {
bitmapLen = activebmp->stride * activebmp->height;
} else {
bitmapLen = activebmp->width * 3;
@@ -1241,7 +1241,7 @@ gdip_save_bmp_image_to_file_stream (void *pointer, GpImage *image, BOOL useFile)
}
scan0 = activebmp->scan0;
- if (activebmp->pixel_format == PixelFormat24bppRgb) {
+ if (activebmp->pixel_format == PixelFormat24bppRGB) {
int width = activebmp->width;
int height = activebmp->height;
int mystride;
View
@@ -336,19 +336,19 @@ typedef enum {
PixelFormatIndexed = 0x00010000, /* flag: is palette-indexed */
PixelFormatPAlpha = 0x00080000, /* flag: alpha is pre-multiplied */
- PixelFormat16bppArgb1555 = 0x00061007,
+ PixelFormat16bppARGB1555 = 0x00061007,
PixelFormat16bppGrayScale = 0x00101004,
- PixelFormat16bppRgb555 = 0x00021005,
- PixelFormat16bppRgb565 = 0x00021006,
+ PixelFormat16bppRGB555 = 0x00021005,
+ PixelFormat16bppRGB565 = 0x00021006,
PixelFormat1bppIndexed = 0x00030101,
- PixelFormat24bppRgb = 0x00021808,
- PixelFormat32bppArgb = 0x0026200a,
- PixelFormat32bppPArgb = 0x000e200b,
- PixelFormat32bppRgb = 0x00022009,
- PixelFormat48bppRgb = 0x0010300c,
+ PixelFormat24bppRGB = 0x00021808,
+ PixelFormat32bppARGB = 0x0026200a,
+ PixelFormat32bppPARGB = 0x000e200b,
+ PixelFormat32bppRGB = 0x00022009,
+ PixelFormat48bppRGB = 0x0010300c,
PixelFormat4bppIndexed = 0x00030402,
- PixelFormat64bppArgb = 0x0034400d,
- PixelFormat64bppPArgb = 0x001c400e,
+ PixelFormat64bppARGB = 0x0034400d,
+ PixelFormat64bppPARGB = 0x001c400e,
PixelFormat8bppIndexed = 0x00030803,
PixelFormatUndefined = 0,
View
@@ -170,7 +170,7 @@ gdip_read_ico_image_from_file_stream (void *pointer, GpImage **image, ImageSourc
result = gdip_bitmap_new_with_frame (NULL, TRUE);
result->type = ImageTypeBitmap;
result->image_format = ICON;
- result->active_bitmap->pixel_format = PixelFormat32bppArgb; /* icons are always promoted to 32 bbp */
+ result->active_bitmap->pixel_format = PixelFormat32bppARGB; /* icons are always promoted to 32 bbp */
result->active_bitmap->width = entry.bWidth;
result->active_bitmap->height = entry.bHeight;
result->active_bitmap->stride = result->active_bitmap->width * 4;
Oops, something went wrong.

0 comments on commit 7b6ebeb

Please sign in to comment.