Author: jordi
Date: 2005-03-22 11:25:14 -0500 (Tue, 22 Mar 2005)
New Revision: 42120
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/bitmap.c
trunk/libgdiplus/src/gdip.h
trunk/libgdiplus/src/image.c
Log:
2005-03-22 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
* image.c, bitmap.c: implement gdip_image_clone to copy Image structs
properly
and fix GdipCloneImage memory corruption problems.
* gdip.h: inline set_pixel_bgra/get_pixel_bgra functions
2005-03-22 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2005-03-22 15:46:22 UTC (rev 42119)
+++ trunk/libgdiplus/src/ChangeLog 2005-03-22 16:25:14 UTC (rev 42120)
@@ -1,5 +1,13 @@
-2005-03-17 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+2005-03-22 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+ * image.c, bitmap.c: implement gdip_image_clone to copy Image structs
properly
+ and fix GdipCloneImage memory corruption problems.
+
+ * gdip.h: inline set_pixel_bgra/get_pixel_bgra functions
+
+
+2005-03-22 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
* bmpcodec.c:
- Fixes 24 bits bitmap loading
- Fixes leaks when exiting on error conditions
Modified: trunk/libgdiplus/src/bitmap.c
===================================================================
--- trunk/libgdiplus/src/bitmap.c 2005-03-22 15:46:22 UTC (rev 42119)
+++ trunk/libgdiplus/src/bitmap.c 2005-03-22 16:25:14 UTC (rev 42120)
@@ -96,7 +96,6 @@
memcpy (result->data.Bytes, bitmap->data.Bytes,
bitmap->data.ByteCount);
}
- result->image.surface = NULL;
/*TODO: We should also copy palette info when we support it*/
}
Modified: trunk/libgdiplus/src/gdip.h
===================================================================
--- trunk/libgdiplus/src/gdip.h 2005-03-22 15:46:22 UTC (rev 42119)
+++ trunk/libgdiplus/src/gdip.h 2005-03-22 16:25:14 UTC (rev 42120)
@@ -1236,8 +1236,8 @@
cairo_surface_t * gdip_bitmap_ensure_surface (GpBitmap *bitmap);
const EncoderParameter *gdip_find_encoder_parameter (GDIPCONST
EncoderParameters *eps, const GUID *guid);
-void set_pixel_bgra (byte* pixel, int index, byte b, byte g, byte r, byte a);
-void get_pixel_bgra (int pixel, byte* b, byte* g, byte* r, byte* a);
+inline void set_pixel_bgra (byte* pixel, int index, byte b, byte g, byte r,
byte a);
+inline void get_pixel_bgra (int pixel, byte* b, byte* g, byte* r, byte* a);
/* Stream handling bits */
typedef int (*GetHeaderDelegate) (unsigned char *, int);
Modified: trunk/libgdiplus/src/image.c
===================================================================
--- trunk/libgdiplus/src/image.c 2005-03-22 15:46:22 UTC (rev 42119)
+++ trunk/libgdiplus/src/image.c 2005-03-22 16:25:14 UTC (rev 42120)
@@ -1127,6 +1127,45 @@
return NotImplemented; /* GdipSetPropertyItem */
}
+void
+gdip_image_clone (GpImage* image, GpImage* clonedImage)
+{
+ int i = 0, j = 0, count = 0, dataCount = 0;
+ BitmapData *data, *clonedData;
+
+ clonedImage->surface = NULL;
+
+ if (image->frameDimensionCount) {
+ clonedImage->frameDimensionCount = image->frameDimensionCount;
+ clonedImage->frameDimensionList = malloc (sizeof (FrameInfo) *
image->frameDimensionCount);
+
+ for (i = 0; i < image->frameDimensionCount; i++) {
+ clonedImage->frameDimensionList[i].count =
image->frameDimensionList[i].count;
+ memcpy
(&clonedImage->frameDimensionList[i].frameDimension,
+ &image->frameDimensionList[i].frameDimension,
sizeof (GUID));
+
+ dataCount = image->frameDimensionList[i].count;
+ data = image->frameDimensionList[i].frames;
+ clonedImage->frameDimensionList[i].frames = malloc
(sizeof (BitmapData) * dataCount);
+ clonedData = clonedImage->frameDimensionList[i].frames;
+ /* Copy all BitmapData */
+ memcpy (clonedImage->frameDimensionList[i].frames,
+ image->frameDimensionList[i].frames, sizeof
(BitmapData) * dataCount);
+
+ for (j = 0; j < dataCount; j++) {
+ if (data[j].Scan0) {
+ clonedData[j].Scan0 = malloc
(data[j].Stride * data[j].Height);
+ memcpy (clonedData[j].Scan0,
data[j].Scan0, data[j].Stride * data[j].Height);
+ }
+ if ((data[j].ByteCount) > 0 && (data[j].Bytes
!= NULL)) {
+ clonedData[j].Bytes = malloc
(data[j].ByteCount);
+ memcpy (clonedData[j].Bytes,
data[j].Bytes, data[j].ByteCount);
+ }
+ }
+ }
+ }
+}
+
GpStatus
GdipCloneImage(GpImage *image, GpImage **cloneImage)
{
@@ -1136,6 +1175,7 @@
switch (image->type){
case imageBitmap:
gdip_bitmap_clone ((GpBitmap *) image, (GpBitmap **)
cloneImage);
+ gdip_image_clone (image, *cloneImage);
break;
case imageMetafile:
return NotImplemented; /* GdipCloneImage -
imageMetafile */
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches