Release 941227

Tue Dec 27 13:35:16 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)

	* [*/Imakefile]
	All objects files are now kept in their respective directory.

	* [README]
	Rewrote most of it.

	* [objects/bitblt.c]
	Rewrote BitBlt() to look right in every case, while minimizing
	the impact on performance. Not really finished yet.

	* [objects/bitmap.c] [objects/dc.c]
	Fixed bug with pattern brushes.

	* [objects/clipping.c] [windows/painting.c]
	Fixes for logical coordinates.

	* [objects/color.c] [windows/graphics.c]
	Fixed GetPixel() to return the correct color, and made it faster.

	* [objects/region.c]
	Fixed bug in CombineRgn() when one of the region is empty.

Fri Dec 22 01:42:57 MET 1994		  Dag Asheim (dash@ifi.uio.no)

	* [Configure]
	Don't assume that expr handles '==', use '=' instead.
	Give a (hopefully informative) message if imake fails.
diff --git a/objects/dib.c b/objects/dib.c
index d841f01..fe2ae9d 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -1,10 +1,9 @@
 /*
- * GDI device independent bitmaps
+ * GDI device-independent bitmaps
  *
- * Copyright 1993 Alexandre Julliard
- *
-static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-*/
+ * Copyright 1993,1994  Alexandre Julliard
+ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/Xlib.h>
@@ -17,23 +16,32 @@
 #include "color.h"
 #include "debug.h"
 
-static int get_bpp(int depth)
+
+/***********************************************************************
+ *           DIB_GetImageWidthBytes
+ *
+ * Return the width of an X image in bytes
+ */
+int DIB_GetImageWidthBytes( int width, int depth )
 {
-	switch(depth) {
-		case 4:
-		case 8:	
-			return 1;
-		case 15:
-		case 16:
-			return 2;
-		case 24:
-			return 4;
-		default:
-			fprintf(stderr, "DIB: unsupported depth %d!\n", depth);
-			exit(1);
-	}		
+    int words;
+
+    switch(depth)
+    {
+    case 1:  words = (width + 31) / 32; break;
+    case 4:  words = (width + 7) / 8; break;
+    case 8:  words = (width + 3) / 4; break;
+    case 15:
+    case 16: words = (width + 1) / 2; break;
+    case 24: words = width; break;
+    default:
+        fprintf(stderr, "DIB: unsupported depth %d.\n", depth );
+        exit(1);
+    }
+    return 4 * words;
 }
 
+
 /***********************************************************************
  *           DIB_BitmapInfoSize
  *
@@ -61,11 +69,11 @@
 {
     extern void _XInitImageFuncPtrs( XImage* );
     XImage * image;
-    int bytesPerLine = bmp->biWidth * get_bpp(bmp->biBitCount);
 
-    image = XCreateImage( display, DefaultVisualOfScreen( screen ),
-			  bmp->biBitCount, ZPixmap, 0, bmpData,
-			  bmp->biWidth, bmp->biHeight, 32, bytesPerLine );
+    image = XCreateImage(display, DefaultVisualOfScreen( screen ),
+                         bmp->biBitCount, ZPixmap, 0, bmpData,
+                         bmp->biWidth, bmp->biHeight, 32,
+                         DIB_GetImageWidthBytes(bmp->biWidth,bmp->biBitCount));
     if (!image) return 0;
     image->byte_order = MSBFirst;
     image->bitmap_bit_order = MSBFirst;
@@ -359,7 +367,7 @@
 			      dprintf_bitmap(stddeb, 
 					     "DIB_SetImageBits_RLE8(): "
 					     "Delta to last line of bitmap "
-					     "(wrongly??) causes loop exit\n");
+					     "(wrongly?) causes loop exit\n");
 			    }
 			  break;
 		      }
@@ -448,8 +456,7 @@
 {
     int *colorMapping;
     XImage *bmpImage;
-    void *bmpData;
-    int i, colors, widthBytes;
+    int i, colors;
 
       /* Build the color mapping table */
 
@@ -477,12 +484,7 @@
     }
 
       /* Transfer the pixels */
-    widthBytes = info->bmiHeader.biWidth * get_bpp(depth);
-
-    bmpData  = malloc( lines * widthBytes );
-    bmpImage = XCreateImage( display, DefaultVisualOfScreen(screen),
-			     depth, ZPixmap, 0, bmpData,
-			     info->bmiHeader.biWidth, lines, 32, widthBytes );
+    XCREATEIMAGE(bmpImage, info->bmiHeader.biWidth, lines, depth );
 
     switch(info->bmiHeader.biBitCount)
     {