Author: pbartok
Date: 2005-03-29 16:52:01 -0500 (Tue, 29 Mar 2005)
New Revision: 42358
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/bitmap.c
trunk/libgdiplus/src/bmpcodec.c
trunk/libgdiplus/src/gdip.h
trunk/libgdiplus/src/imageattributes.c
Log:
2005-03-29 Peter Bartok <[EMAIL PROTECTED]>
* bitmap.c: Removed set_pixel_bgra() and get_pixel_bgra() functions,
re-made them as macros, since inlining only works for static functions
* gdip.h: Added set/get_pixel_bgra macros; removed prototypes
* imageattributes.c: Fixed code to work with set/get_pixel_bgra macros
* bmpcodec.c: Added code to deal with the (wrong) assumption that
Stream.Read will always return the number of bytes requested if the
stream end has not been hit (related to bug #72588)
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2005-03-29 21:36:49 UTC (rev 42357)
+++ trunk/libgdiplus/src/ChangeLog 2005-03-29 21:52:01 UTC (rev 42358)
@@ -1,3 +1,13 @@
+2005-03-29 Peter Bartok <[EMAIL PROTECTED]>
+
+ * bitmap.c: Removed set_pixel_bgra() and get_pixel_bgra() functions,
+ re-made them as macros, since inlining only works for static functions
+ * gdip.h: Added set/get_pixel_bgra macros; removed prototypes
+ * imageattributes.c: Fixed code to work with set/get_pixel_bgra macros
+ * bmpcodec.c: Added code to deal with the (wrong) assumption that
+ Stream.Read will always return the number of bytes requested if the
+ stream end has not been hit (related to bug #72588)
+
2005-03-22 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
* image.c, bitmap.c: implement gdip_image_clone to copy Image structs
properly
Modified: trunk/libgdiplus/src/bitmap.c
===================================================================
--- trunk/libgdiplus/src/bitmap.c 2005-03-29 21:36:49 UTC (rev 42357)
+++ trunk/libgdiplus/src/bitmap.c 2005-03-29 21:52:01 UTC (rev 42358)
@@ -970,38 +970,3 @@
return bitmap->image.surface;
}
-
-#ifdef WORDS_BIGENDIAN
-void set_pixel_bgra (byte* pixel, int index, byte b, byte g, byte r, byte a)
-{
- pixel[index+0] = a;
- pixel[index+1] = r;
- pixel[index+2] = g;
- pixel[index+3] = b;
-}
-
-void get_pixel_bgra (int pixel, byte* b, byte* g, byte* r, byte* a)
-{
- *b = (pixel & 0xff000000) >> 24;
- *g = (pixel & 0x00ff0000) >> 16;
- *r = (pixel & 0x0000ff00) >> 8;
- *a = (pixel & 0x000000ff);
-}
-
-#else
-void set_pixel_bgra (byte* pixel, int index, byte b, byte g, byte r, byte a)
-{
- pixel[index+0] = b;
- pixel[index+1] = g;
- pixel[index+2] = r;
- pixel[index+3] = a;
-}
-
-void get_pixel_bgra (int pixel, byte* b, byte* g, byte* r, byte* a)
-{
- *a = ((pixel & 0xff000000) >> 24);
- *r = ((pixel & 0x00ff0000) >> 16);
- *g = ((pixel & 0x0000ff00) >> 8);
- *b = (pixel & 0x000000ff);
-}
-#endif
Modified: trunk/libgdiplus/src/bmpcodec.c
===================================================================
--- trunk/libgdiplus/src/bmpcodec.c 2005-03-29 21:36:49 UTC (rev 42357)
+++ trunk/libgdiplus/src/bmpcodec.c 2005-03-29 21:52:01 UTC (rev 42358)
@@ -549,10 +549,28 @@
int
gdip_read_bmp_data (void *pointer, byte *data, int size, bool useFile)
{
- if (useFile)
+ if (useFile) {
return fread (data, 1, size, (FILE*) pointer);
- else
- return ((GetBytesDelegate)(pointer))(data, size, 0);
+ } else {
+ // Streams are not required to return the number of bytes
+ // requested, they could return less yet our code seems to
assume
+ // it will always get what it's asking for; lets loop until we
+ // get what was requested or we get an error
+ int got;
+ int total;
+
+ total = 0;
+
+ do {
+ got = ((GetBytesDelegate)(pointer))(data + total, size
- total, 0);
+ if (got < 1) { // 0 = end of stream, -1 = error
+ return total;
+ }
+ total += got;
+ } while (total < size);
+
+ return total;
+ }
}
GpStatus
Modified: trunk/libgdiplus/src/gdip.h
===================================================================
--- trunk/libgdiplus/src/gdip.h 2005-03-29 21:36:49 UTC (rev 42357)
+++ trunk/libgdiplus/src/gdip.h 2005-03-29 21:52:01 UTC (rev 42358)
@@ -43,6 +43,34 @@
#define gdip_cairo_ft_font_lock_face(font) cairo_ft_font_face(font)
#define gdip_cairo_ft_font_unlock_face(font)
+#ifdef WORDS_BIGENDIAN
+#define set_pixel_bgra(pixel,index,b,g,r,a) { \
+ pixel[index+0] = a; \
+ pixel[index+1] = r; \
+ pixel[index+2] = g; \
+ pixel[index+3] = b; \
+ }
+#define get_pixel_bgra(color, b, g, r, a) { \
+ a = (color & 0x000000ff); \
+ r = (color & 0x0000ff00) >> 8; \
+ g = (color & 0x00ff0000) >> 16; \
+ b = (color & 0xff000000) >> 24; \
+ }
+#else
+#define set_pixel_bgra(pixel,index,b,g,r,a) { \
+ pixel[index+0] = b; \
+ pixel[index+1] = g; \
+ pixel[index+2] = r; \
+ pixel[index+3] = a; \
+ }
+#define get_pixel_bgra(color, b, g, r, a) { \
+ a = ((color & 0xff000000) >> 24); \
+ r = ((color & 0x00ff0000) >> 16); \
+ g = ((color & 0x0000ff00) >> 8); \
+ b = (color & 0x000000ff); \
+ }
+#endif
+
#ifdef CAIRO_HAS_XLIB_SURFACE
#ifdef USE_INCLUDED_CAIRO
#include <cairo-xlib.h>
@@ -1236,8 +1264,6 @@
cairo_surface_t * gdip_bitmap_ensure_surface (GpBitmap *bitmap);
const EncoderParameter *gdip_find_encoder_parameter (GDIPCONST
EncoderParameters *eps, const GUID *guid);
-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/imageattributes.c
===================================================================
--- trunk/libgdiplus/src/imageattributes.c 2005-03-29 21:36:49 UTC (rev
42357)
+++ trunk/libgdiplus/src/imageattributes.c 2005-03-29 21:52:01 UTC (rev
42358)
@@ -80,6 +80,7 @@
GpBitmap bmpdest;
int x,y, cnt;
ARGB color;
+ byte *color_p = (byte *)&color;
*allocated = FALSE;
@@ -188,7 +189,7 @@
int r_new,g_new,b_new,a_new;
GdipBitmapGetPixel (&bmpdest, x, y, &color);
- get_pixel_bgra (color, &b, &g, &r, &a);
+ get_pixel_bgra (color, b, g, r, a);
r_new = (r * imgattr->colormatrix->m[0][0] + g
* imgattr->colormatrix->m[1][0] + b * imgattr->colormatrix->m[2][0] +
a * imgattr->colormatrix->m[3][0] +
(255 * imgattr->colormatrix->m[4][0]));
@@ -207,7 +208,7 @@
if (b_new > 0xff) b_new = 0xff;
if (a_new > 0xff) a_new = 0xff;
- set_pixel_bgra ((byte *)&color, 0, (byte)
b_new, (byte) g_new, (byte) r_new, (byte) a_new);
+ set_pixel_bgra (color_p, 0, (byte) b_new,
(byte) g_new, (byte) r_new, (byte) a_new);
GdipBitmapSetPixel (&bmpdest, x, y, color);
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches