Release 960606
[wine/multimedia.git] / win32 / gdi32.c
blob782c0b32efa23ec4359cdba0ddafa9fa7f680a87
2 /*
3 * Win32 GDI functions
5 * Copyright 1996 Thomas Sandford t.d.g.sandford@prds-grn.demon.co.uk
6 */
8 #include <windows.h>
9 #include <gdi.h>
10 #include <pen.h>
11 #include <brush.h>
12 #include <bitmap.h>
13 #include <font.h>
14 #include <palette.h>
15 #include <debug.h>
17 int WIN32_GetObject( HANDLE handle, int count, LPVOID buffer )
19 /* largely a copy of GetObject, but with size mangling capabilities to
20 convert between win16 and win32 objects. Yeuch! */
23 void *temp = alloca(count);
24 GDIOBJHDR * ptr = NULL;
26 dprintf_win32(stddeb, "WIN32_GetObject: %d %d %p\n", handle, count, buffer);
28 if ((!count) || (temp == NULL))
29 return 0;
31 ptr = GDI_GetObjPtr(handle, MAGIC_DONTCARE);
32 if (!ptr) return 0;
34 /* FIXME: only bitmaps fixed so far */
36 switch(ptr->wMagic)
38 case PEN_MAGIC:
39 return PEN_GetObject( (PENOBJ *)ptr, count, buffer );
40 case BRUSH_MAGIC:
41 return BRUSH_GetObject( (BRUSHOBJ *)ptr, count, buffer );
42 case BITMAP_MAGIC: {
43 BITMAP *pbm = (BITMAP *)temp;
44 int *pdest = (int *)buffer;
46 if (buffer == NULL)
47 return 28;
49 BITMAP_GetObject( (BITMAPOBJ *)ptr, count, temp );
50 if (count > 3)
51 pdest[0] = pbm->bmType;
52 if (count > 7)
53 pdest[1] = pbm->bmWidth;
54 if (count > 11)
55 pdest[2] = pbm->bmHeight;
56 if (count > 15)
57 pdest[3] = pbm->bmWidthBytes;
58 if (count > 19)
59 pdest[4] = pbm->bmPlanes;
60 if (count > 23)
61 pdest[5] = pbm->bmBitsPixel;
62 if (count > 27)
63 pdest[6] = pbm->bmBits;
65 return (count > 28) ? 28 : count - (count % 4);
67 case FONT_MAGIC:
68 return FONT_GetObject( (FONTOBJ *)ptr, count, buffer );
69 case PALETTE_MAGIC:
70 return PALETTE_GetObject( (PALETTEOBJ *)ptr, count, buffer );
72 return 0;