Release 980614
[wine/multimedia.git] / graphics / x11drv / bitmap.c
blobd9aa9816e8f67721152eb7d2eaa512bb74dbdc05
1 /*
2 * GDI bitmap objects
4 * Copyright 1993 Alexandre Julliard
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "ts_xlib.h"
10 #include "ts_xutil.h"
11 #include "gdi.h"
12 #include "callback.h"
13 #include "dc.h"
14 #include "bitmap.h"
15 #include "heap.h"
16 #include "debug.h"
18 /***********************************************************************
19 * X11DRV_BITMAP_Init
21 BOOL32 X11DRV_BITMAP_Init(void)
23 Pixmap tmpPixmap;
25 /* Create the necessary GCs */
27 if ((tmpPixmap = TSXCreatePixmap( display, rootWindow, 1, 1, 1 )))
29 BITMAP_monoGC = TSXCreateGC( display, tmpPixmap, 0, NULL );
30 TSXSetGraphicsExposures( display, BITMAP_monoGC, False );
31 TSXFreePixmap( display, tmpPixmap );
34 if (screenDepth != 1)
36 if ((tmpPixmap = TSXCreatePixmap(display, rootWindow, 1,1,screenDepth)))
38 BITMAP_colorGC = TSXCreateGC( display, tmpPixmap, 0, NULL );
39 TSXSetGraphicsExposures( display, BITMAP_colorGC, False );
40 TSXFreePixmap( display, tmpPixmap );
43 return TRUE;
46 /***********************************************************************
47 * X11DRV_BITMAP_SelectObject
49 HBITMAP32 X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP32 hbitmap,
50 BITMAPOBJ * bmp )
52 HRGN32 hrgn;
53 HBITMAP32 prevHandle = dc->w.hBitmap;
55 if (!(dc->w.flags & DC_MEMORY)) return 0;
57 if (dc->w.hVisRgn)
58 SetRectRgn32( dc->w.hVisRgn, 0, 0,
59 bmp->bitmap.bmWidth, bmp->bitmap.bmHeight );
60 else
62 hrgn = CreateRectRgn32(0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight);
63 if (!hrgn) return 0;
64 dc->w.hVisRgn = hrgn;
67 dc->u.x.drawable = bmp->pixmap;
68 dc->w.hBitmap = hbitmap;
70 /* Change GC depth if needed */
72 if (dc->w.bitsPerPixel != bmp->bitmap.bmBitsPixel)
74 TSXFreeGC( display, dc->u.x.gc );
75 dc->u.x.gc = TSXCreateGC( display, dc->u.x.drawable, 0, NULL );
76 dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
77 DC_InitDC( dc );
79 else CLIPPING_UpdateGCRegion( dc ); /* Just update GC clip region */
80 return prevHandle;