Author: spouliot
Date: 2007-05-15 16:09:49 -0400 (Tue, 15 May 2007)
New Revision: 77434
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/graphics-private.h
trunk/libgdiplus/src/image.c
Log:
2007-05-15 Sebastien Pouliot <[EMAIL PROTECTED]>
* graphics-private.h: Add macro to check for position overflows.
* image.c: Check for negative width/height values and overflows
in function GdipDrawImageRect (not applicable to metafiles).
Check GpUnit inside function GdipDrawImageRectRect.
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2007-05-15 19:35:18 UTC (rev 77433)
+++ trunk/libgdiplus/src/ChangeLog 2007-05-15 20:09:49 UTC (rev 77434)
@@ -1,3 +1,10 @@
+2007-05-15 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * graphics-private.h: Add macro to check for position overflows.
+ * image.c: Check for negative width/height values and overflows
+ in function GdipDrawImageRect (not applicable to metafiles).
+ Check GpUnit inside function GdipDrawImageRectRect.
+
2007-05-12 Miguel de Icaza <[EMAIL PROTECTED]>
* image.c (GdipDrawImageRect): Passing a width or height of 0 is a
Modified: trunk/libgdiplus/src/graphics-private.h
===================================================================
--- trunk/libgdiplus/src/graphics-private.h 2007-05-15 19:35:18 UTC (rev
77433)
+++ trunk/libgdiplus/src/graphics-private.h 2007-05-15 20:09:49 UTC (rev
77434)
@@ -52,6 +52,10 @@
/* Recursion depth of the flattening algorithm */
#define FLATTEN_RECURSION_LIMIT 10
+/* not 100% identical to MS GDI+ which varies a little from int and float, but
still around 0x40000000 */
+#define GDIP_MAX_COORD 1073741824
+#define gdip_is_overflow(a) (((a) < -GDIP_MAX_COORD) || ((a) >
GDIP_MAX_COORD))
+
typedef enum {
CURVE_OPEN,
CURVE_CLOSE
Modified: trunk/libgdiplus/src/image.c
===================================================================
--- trunk/libgdiplus/src/image.c 2007-05-15 19:35:18 UTC (rev 77433)
+++ trunk/libgdiplus/src/image.c 2007-05-15 20:09:49 UTC (rev 77434)
@@ -376,10 +376,14 @@
if (!graphics || !image)
return InvalidParameter;
- if (width == 0 || height == 0)
+ if ((width <= 0) || (height <= 0))
return Ok;
if (image->type == ImageTypeBitmap) {
+ /* check does not apply to metafiles, and it's better be done
before converting the image */
+ if (gdip_is_overflow(x) || gdip_is_overflow(y))
+ return ValueOverflow;
+
if (gdip_is_an_indexed_pixelformat
(image->active_bitmap->pixel_format)) {
GpStatus status = OutOfMemory;
GpBitmap *rgb_bitmap = gdip_convert_indexed_to_rgb
(image);
@@ -574,6 +578,22 @@
if (!graphics || !image)
return InvalidParameter;
+ switch (srcUnit) {
+ case UnitPixel:
+ break;
+ case UnitPoint:
+ case UnitInch:
+ case UnitDocument:
+ case UnitMillimeter:
+ if (graphics->type != gtPostScript)
+ return NotImplemented; /* GDI+ returns the same */
+ break;
+ case UnitWorld:
+ case UnitDisplay:
+ default:
+ return InvalidParameter;
+ }
+
if (image->type == ImageTypeBitmap) {
if (gdip_is_an_indexed_pixelformat
(image->active_bitmap->pixel_format)) {
GpStatus status = OutOfMemory;
@@ -588,6 +608,9 @@
return status;
}
+ } else {
+ /* metafile support */
+ return NotImplemented;
}
/* see OPTIMIZE_CONVERSION in general.h */
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches