[cairo-commit] cairo/src cairo-png.c, 1.11, 1.12 cairo-wideint.h, 1.9, 1.10

Carl Worth commit at pdx.freedesktop.org
Tue May 10 12:42:34 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv21965/src

Modified Files:
	cairo-png.c cairo-wideint.h 
Log Message:

        * src/cairo-wideint.h: Don't guess and make our own definitions
        for uint8_t, etc. Just error out if we can't find a suitable
        header file.

        * src/cairo-png.c: (unpremultiply_data), (premultiply_data):
        * test/read-png.c: (premultiply_data): Fix to use fixed-size type
        so that this code works when sizeof(unsigned long) != 32. Thanks
        to Manish Singh.


Index: cairo-png.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-png.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cairo-png.c	3 May 2005 15:33:32 -0000	1.11
+++ cairo-png.c	10 May 2005 19:42:32 -0000	1.12
@@ -44,11 +44,11 @@
     int i;
 
     for (i = 0; i < row_info->rowbytes; i += 4) {
-        unsigned char *b = &data[i];
-        unsigned int pixel;
-        unsigned char alpha;
+        uint8_t *b = &data[i];
+        uint32_t pixel;
+        uint8_t  alpha;
 
-	memcpy (&pixel, b, sizeof (unsigned int));
+	memcpy (&pixel, b, sizeof (uint32_t));
 	alpha = (pixel & 0xff000000) >> 24;
         if (alpha == 0) {
 	    b[0] = b[1] = b[2] = b[3] = 0;
@@ -268,18 +268,18 @@
     int i;
 
     for (i = 0; i < row_info->rowbytes; i += 4) {
-	unsigned char  *base = &data[i];
-	unsigned char  blue = base[0];
-	unsigned char  green = base[1];
-	unsigned char  red = base[2];
-	unsigned char  alpha = base[3];
-	unsigned long	p;
+	uint8_t *base = &data[i];
+	uint8_t  blue = base[0];
+	uint8_t  green = base[1];
+	uint8_t  red = base[2];
+	uint8_t  alpha = base[3];
+	uint32_t p;
 
 	red = ((unsigned) red * (unsigned) alpha + 127) / 255;
 	green = ((unsigned) green * (unsigned) alpha + 127) / 255;
 	blue = ((unsigned) blue * (unsigned) alpha + 127) / 255;
 	p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
-	memcpy (base, &p, sizeof (unsigned long));
+	memcpy (base, &p, sizeof (uint32_t));
     }
 }
 

Index: cairo-wideint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-wideint.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cairo-wideint.h	7 Apr 2005 22:00:46 -0000	1.9
+++ cairo-wideint.h	10 May 2005 19:42:32 -0000	1.10
@@ -45,12 +45,7 @@
 #elif HAVE_SYS_INT_TYPES_H
 # include <sys/int_types.h>
 #else
-typedef signed char int8_t;
-typedef short int16_t;
-typedef long int32_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned long uint32_t;
+#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
 #endif
 
 /*




More information about the cairo-commit mailing list