Release 970305
[wine/multimedia.git] / graphics / x11drv / bitmap.c
blobb302248d3c4e8575cfa594afeab09b2c3f540718
1 /*
2 * GDI bitmap objects
4 * Copyright 1993 Alexandre Julliard
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <X11/Xlib.h>
10 #include <X11/Xutil.h>
11 #include "gdi.h"
12 #include "callback.h"
13 #include "dc.h"
14 #include "bitmap.h"
15 #include "heap.h"
16 #include "stddebug.h"
17 #include "debug.h"
19 /***********************************************************************
20 * X11DRV_BITMAP_Init
22 BOOL32 X11DRV_BITMAP_Init(void)
24 Pixmap tmpPixmap;
26 /* Create the necessary GCs */
28 if ((tmpPixmap = XCreatePixmap( display, rootWindow, 1, 1, 1 )))
30 BITMAP_monoGC = XCreateGC( display, tmpPixmap, 0, NULL );
31 XSetGraphicsExposures( display, BITMAP_monoGC, False );
32 XFreePixmap( display, tmpPixmap );
35 if (screenDepth != 1)
37 if ((tmpPixmap = XCreatePixmap(display, rootWindow, 1,1,screenDepth)))
39 BITMAP_colorGC = XCreateGC( display, tmpPixmap, 0, NULL );
40 XSetGraphicsExposures( display, BITMAP_colorGC, False );
41 XFreePixmap( display, tmpPixmap );
44 return TRUE;
47 /***********************************************************************
48 * X11DRV_BITMAP_SelectObject
50 HBITMAP32 X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP32 hbitmap,
51 BITMAPOBJ * bmp )
53 HRGN32 hrgn;
54 HBITMAP32 prevHandle = dc->w.hBitmap;
56 if (!(dc->w.flags & DC_MEMORY)) return 0;
58 if (dc->w.hVisRgn)
59 SetRectRgn32( dc->w.hVisRgn, 0, 0,
60 bmp->bitmap.bmWidth, bmp->bitmap.bmHeight );
61 else
63 hrgn = CreateRectRgn32(0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight);
64 if (!hrgn) return 0;
65 dc->w.hVisRgn = hrgn;
68 dc->u.x.drawable = bmp->pixmap;
69 dc->w.hBitmap = hbitmap;
71 /* Change GC depth if needed */
73 if (dc->w.bitsPerPixel != bmp->bitmap.bmBitsPixel)
75 XFreeGC( display, dc->u.x.gc );
76 dc->u.x.gc = XCreateGC( display, dc->u.x.drawable, 0, NULL );
77 dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
78 DC_InitDC( dc );
80 else CLIPPING_UpdateGCRegion( dc ); /* Just update GC clip region */
81 return prevHandle;