Author: spouliot
Date: 2007-01-11 13:14:58 -0500 (Thu, 11 Jan 2007)
New Revision: 70871
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/bitmap.c
trunk/libgdiplus/src/image.c
Log:
2007-01-11 Sebastien Pouliot <[EMAIL PROTECTED]>
* bitmap.c: Fix GdipCreateBitmapFromScan0 to initialize the flags to 2
(HasAlpha) if the format supports alpha;
* image.c: Copy all palette (including flags and count) in function
GdipSetImagePalette. Re-adjust the size if the palette size is
different. Fix palette handling not to return errors for an unexisting
palette (but return a default empty one).
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2007-01-11 18:01:09 UTC (rev 70870)
+++ trunk/libgdiplus/src/ChangeLog 2007-01-11 18:14:58 UTC (rev 70871)
@@ -1,3 +1,12 @@
+2007-01-11 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * bitmap.c: Fix GdipCreateBitmapFromScan0 to initialize the flags to 2
+ (HasAlpha) if the format supports alpha;
+ * image.c: Copy all palette (including flags and count) in function
+ GdipSetImagePalette. Re-adjust the size if the palette size is
+ different. Fix palette handling not to return errors for an unexisting
+ palette (but return a default empty one).
+
2007-01-10 Sebastien Pouliot <[EMAIL PROTECTED]>
* bmpcodec.c|h: Refactor some decoding code to share with the ICON
Modified: trunk/libgdiplus/src/bitmap.c
===================================================================
--- trunk/libgdiplus/src/bitmap.c 2007-01-11 18:01:09 UTC (rev 70870)
+++ trunk/libgdiplus/src/bitmap.c 2007-01-11 18:14:58 UTC (rev 70871)
@@ -781,6 +781,7 @@
GpBitmap *result;
BitmapData *bitmap_data;
int cairo_format;
+ int flags = 0;
if (width <= 0 || height <= 0) {
return InvalidParameter;
@@ -796,6 +797,7 @@
case Format32bppRgb:
case Format32bppPArgb: {
cairo_format = CAIRO_FORMAT_ARGB32;
+ flags = 2;
break;
}
@@ -845,6 +847,7 @@
bitmap_data->width = width;
bitmap_data->height = height;
bitmap_data->pixel_format = format;
+ bitmap_data->image_flags = flags;
if (stride == 0) {
if (gdip_is_an_indexed_pixelformat(format)) {
Modified: trunk/libgdiplus/src/image.c
===================================================================
--- trunk/libgdiplus/src/image.c 2007-01-11 18:01:09 UTC (rev 70870)
+++ trunk/libgdiplus/src/image.c 2007-01-11 18:14:58 UTC (rev 70871)
@@ -1468,8 +1468,13 @@
int palette_entries;
int bytes_needed;
- if ((image == NULL) || (palette == NULL) ||
(image->active_bitmap->palette == NULL)) {
+ if (!image || !palette)
return InvalidParameter;
+
+ if (!image->active_bitmap->palette) {
+ image->active_bitmap->palette = (ColorPalette*) GdipAlloc
(sizeof(ColorPalette) - sizeof(ARGB));
+ image->active_bitmap->palette->Flags = 0;
+ image->active_bitmap->palette->Count = 0;
}
palette_entries = image->active_bitmap->palette->Count;
@@ -1478,7 +1483,7 @@
palette_entries = 16;
}
- bytes_needed = palette_entries * sizeof(ARGB) + sizeof(ColorPalette) -
sizeof(ARGB);
+ bytes_needed = (palette_entries - 1) * sizeof(ARGB) +
sizeof(ColorPalette);
if (bytes_needed > size) {
return InvalidParameter;
@@ -1491,18 +1496,19 @@
GpStatus
GdipSetImagePalette (GpImage *image, GDIPCONST ColorPalette *palette)
{
- int entries_to_copy;
+ int size;
- if ((image == NULL) || (palette == NULL) ||
(image->active_bitmap->palette == NULL)) {
+ if (!image || !palette)
return InvalidParameter;
- }
- entries_to_copy = image->active_bitmap->palette->Count;
- if (entries_to_copy > palette->Count) {
- entries_to_copy = palette->Count;
+ size = (palette->Count - 1) * sizeof(ARGB) + sizeof(ColorPalette);
+ if (!image->active_bitmap->palette || (palette->Count !=
image->active_bitmap->palette->Count)) {
+ if (image->active_bitmap->palette)
+ GdipFree (image->active_bitmap->palette);
+ image->active_bitmap->palette = (ColorPalette*) GdipAlloc
(size);
}
- memcpy(image->active_bitmap->palette->Entries, palette->Entries,
entries_to_copy * sizeof(ARGB));
+ memcpy (image->active_bitmap->palette, palette, size);
return Ok;
}
@@ -1511,17 +1517,16 @@
{
int palette_entries;
- if ((image == NULL) || (size == NULL) ||
(image->active_bitmap->palette == NULL)) {
+ if (!image || !size)
return InvalidParameter;
- }
- palette_entries = image->active_bitmap->palette->Count;
+ palette_entries = (image->active_bitmap->palette) ?
image->active_bitmap->palette->Count : 0;
if ((image->type == imageBitmap) &&
(image->active_bitmap->pixel_format == Format4bppIndexed)) {
palette_entries = 16;
}
- *size = palette_entries * sizeof(ARGB) + sizeof(ColorPalette) -
sizeof(ARGB);
+ *size = (palette_entries - 1) * sizeof(ARGB) + sizeof(ColorPalette);
return Ok;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches