4 * Copyright 1993 Alexandre Julliard
20 #ifdef PRELIMINARY_WING16_SUPPORT
21 #include <sys/types.h>
26 /* GCs used for B&W and color bitmap operations */
27 GC BITMAP_monoGC
= 0, BITMAP_colorGC
= 0;
29 /***********************************************************************
32 * Wrapper to call XPutImage with CALL_LARGE_STACK.
35 struct XPutImage_descr
43 static int XPutImage_wrapper( const struct XPutImage_descr
*descr
)
45 return XPutImage( display
, descr
->bmp
->pixmap
, BITMAP_GC(descr
->bmp
),
46 descr
->image
, 0, 0, 0, 0, descr
->width
, descr
->height
);
49 /***********************************************************************
50 * BITMAP_GetBitsPadding
52 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
54 INT32
BITMAP_GetBitsPadding( int bmWidth
, int bpp
)
61 if (!(bmWidth
& 15)) pad
= 0;
62 else pad
= ((16 - (bmWidth
& 15)) + 7) / 8;
66 pad
= (2 - (bmWidth
& 1)) & 1;
70 pad
= (bmWidth
*3) & 1;
76 pad
= 0; /* we have 16bit alignment already */
80 if (!(bmWidth
& 3)) pad
= 0;
81 else pad
= ((4 - (bmWidth
& 3)) + 1) / 2;
85 fprintf(stderr
,"GetBitsPadding: unknown depth %d, please report.\n", bpp
);
91 /***********************************************************************
94 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB data.
96 INT32
BITMAP_GetBitsWidth( int bmWidth
, int bpp
)
101 return 2 * ((bmWidth
+15) >> 4);
104 bmWidth
*= 3; /* fall through */
106 return bmWidth
+ (bmWidth
& 1);
116 return 2 * ((bmWidth
+3) >> 2);
119 fprintf(stderr
,"GetBitsPadding: unknown depth %d, please report.\n", bpp
);
124 /***********************************************************************
125 * CreateBitmap16 (GDI.48)
127 HBITMAP16 WINAPI
CreateBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
128 UINT16 bpp
, LPCVOID bits
)
130 return CreateBitmap32( width
, height
, planes
, bpp
, bits
);
134 /***********************************************************************
135 * CreateBitmap32 (GDI32.25)
137 HBITMAP32 WINAPI
CreateBitmap32( INT32 width
, INT32 height
, UINT32 planes
,
138 UINT32 bpp
, LPCVOID bits
)
140 BITMAPOBJ
* bmpObjPtr
;
143 planes
= (BYTE
)planes
;
146 dprintf_gdi( stddeb
, "CreateBitmap: %dx%d, %d colors\n",
147 width
, height
, 1 << (planes
*bpp
) );
149 /* Check parameters */
150 if (!height
|| !width
|| planes
!= 1) return 0;
151 if ((bpp
!= 1) && (bpp
!= screenDepth
)) return 0;
152 if (height
< 0) height
= -height
;
153 if (width
< 0) width
= -width
;
155 /* Create the BITMAPOBJ */
156 hbitmap
= GDI_AllocObject( sizeof(BITMAPOBJ
), BITMAP_MAGIC
);
157 if (!hbitmap
) return 0;
158 bmpObjPtr
= (BITMAPOBJ
*) GDI_HEAP_LOCK( hbitmap
);
160 bmpObjPtr
->size
.cx
= 0;
161 bmpObjPtr
->size
.cy
= 0;
162 bmpObjPtr
->bitmap
.bmType
= 0;
163 bmpObjPtr
->bitmap
.bmWidth
= (INT16
)width
;
164 bmpObjPtr
->bitmap
.bmHeight
= (INT16
)height
;
165 bmpObjPtr
->bitmap
.bmPlanes
= (BYTE
)planes
;
166 bmpObjPtr
->bitmap
.bmBitsPixel
= (BYTE
)bpp
;
167 bmpObjPtr
->bitmap
.bmWidthBytes
= (INT16
)BITMAP_WIDTH_BYTES( width
, bpp
);
168 bmpObjPtr
->bitmap
.bmBits
= NULL
;
170 /* Create the pixmap */
171 bmpObjPtr
->pixmap
= TSXCreatePixmap(display
, rootWindow
, width
, height
, bpp
);
172 if (!bmpObjPtr
->pixmap
)
174 GDI_HEAP_FREE( hbitmap
);
177 else if (bits
) /* Set bitmap bits */
178 SetBitmapBits32( hbitmap
, height
* bmpObjPtr
->bitmap
.bmWidthBytes
,
180 GDI_HEAP_UNLOCK( hbitmap
);
185 /***********************************************************************
186 * CreateCompatibleBitmap16 (GDI.51)
188 HBITMAP16 WINAPI
CreateCompatibleBitmap16(HDC16 hdc
, INT16 width
, INT16 height
)
190 return CreateCompatibleBitmap32( hdc
, width
, height
);
194 /***********************************************************************
195 * CreateCompatibleBitmap32 (GDI32.30)
197 HBITMAP32 WINAPI
CreateCompatibleBitmap32(HDC32 hdc
, INT32 width
, INT32 height
)
199 HBITMAP32 hbmpRet
= 0;
202 dprintf_gdi( stddeb
, "CreateCompatibleBitmap(%04x,%d,%d) = \n",
203 hdc
, width
, height
);
204 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
205 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
206 dprintf_gdi(stddeb
,"\t\t%04x\n", hbmpRet
);
211 /***********************************************************************
212 * CreateBitmapIndirect16 (GDI.49)
214 HBITMAP16 WINAPI
CreateBitmapIndirect16( const BITMAP16
* bmp
)
216 return CreateBitmap16( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
217 bmp
->bmBitsPixel
, PTR_SEG_TO_LIN( bmp
->bmBits
) );
221 /***********************************************************************
222 * CreateBitmapIndirect32 (GDI32.26)
224 HBITMAP32 WINAPI
CreateBitmapIndirect32( const BITMAP32
* bmp
)
226 return CreateBitmap32( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
227 bmp
->bmBitsPixel
, bmp
->bmBits
);
231 /***********************************************************************
234 * Get an X image for a bitmap. For use with CALL_LARGE_STACK.
236 XImage
*BITMAP_GetXImage( const BITMAPOBJ
*bmp
)
238 return XGetImage( display
, bmp
->pixmap
, 0, 0, bmp
->bitmap
.bmWidth
,
239 bmp
->bitmap
.bmHeight
, AllPlanes
, ZPixmap
);
243 /***********************************************************************
244 * GetBitmapBits16 (GDI.74)
246 LONG WINAPI
GetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPVOID buffer
)
248 return GetBitmapBits32( hbitmap
, count
, buffer
);
252 /***********************************************************************
253 * GetBitmapBits32 (GDI32.143)
255 LONG WINAPI
GetBitmapBits32( HBITMAP32 hbitmap
, LONG count
, LPVOID buffer
)
258 LONG height
, old_height
;
265 fprintf(stderr
, "Negative number of bytes (%ld) passed to GetBitmapBits???\n", count
);
268 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
271 /* Only get entire lines */
272 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
273 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
275 dprintf_bitmap(stddeb
, "GetBitmapBits: %dx%d %d colors %p fetched height: %ld\n",
276 bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
277 1 << bmp
->bitmap
.bmBitsPixel
, buffer
, height
);
279 pad
= BITMAP_GetBitsPadding( bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmBitsPixel
);
281 if (!height
|| (pad
== -1))
283 GDI_HEAP_UNLOCK( hbitmap
);
287 EnterCriticalSection( &X11DRV_CritSection
);
289 /* Hack: change the bitmap height temporarily to avoid */
290 /* getting unnecessary bitmap rows. */
291 old_height
= bmp
->bitmap
.bmHeight
;
292 bmp
->bitmap
.bmHeight
= height
;
293 image
= (XImage
*)CALL_LARGE_STACK( BITMAP_GetXImage
, bmp
);
294 bmp
->bitmap
.bmHeight
= old_height
;
296 /* copy XImage to 16 bit padded image buffer with real bitsperpixel */
299 switch (bmp
->bitmap
.bmBitsPixel
)
302 for (h
=0;h
<height
;h
++)
305 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
309 *tbuf
|= XGetPixel(image
,w
,h
)<<(7-(w
&7));
310 if ((w
&7) == 7) ++tbuf
;
316 for (h
=0;h
<height
;h
++)
318 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
320 if (!(w
& 1)) *tbuf
= XGetPixel( image
, w
, h
) << 4;
321 else *tbuf
++ |= XGetPixel( image
, w
, h
) & 0x0f;
327 for (h
=0;h
<height
;h
++)
329 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
330 *tbuf
++ = XGetPixel(image
,w
,h
);
336 for (h
=0;h
<height
;h
++)
338 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
340 long pixel
= XGetPixel(image
,w
,h
);
342 *tbuf
++ = pixel
& 0xff;
343 *tbuf
++ = (pixel
>>8) & 0xff;
348 for (h
=0;h
<height
;h
++)
350 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
352 long pixel
= XGetPixel(image
,w
,h
);
354 *tbuf
++ = pixel
& 0xff;
355 *tbuf
++ = (pixel
>> 8) & 0xff;
356 *tbuf
++ = (pixel
>>16) & 0xff;
361 XDestroyImage( image
);
362 LeaveCriticalSection( &X11DRV_CritSection
);
364 GDI_HEAP_UNLOCK( hbitmap
);
365 return height
* bmp
->bitmap
.bmWidthBytes
;
369 /***********************************************************************
370 * SetBitmapBits16 (GDI.106)
372 LONG WINAPI
SetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPCVOID buffer
)
374 return SetBitmapBits32( hbitmap
, count
, buffer
);
378 /***********************************************************************
379 * SetBitmapBits32 (GDI32.303)
381 LONG WINAPI
SetBitmapBits32( HBITMAP32 hbitmap
, LONG count
, LPCVOID buffer
)
383 struct XPutImage_descr descr
;
387 LPBYTE sbuf
,tmpbuffer
;
388 int w
,h
,pad
,widthbytes
;
392 fprintf(stderr
, "Negative number of bytes (%ld) passed to SetBitmapBits???\n", count
);
395 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
398 dprintf_bitmap(stddeb
, "SetBitmapBits: %dx%d %d colors %p\n",
399 bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
400 1 << bmp
->bitmap
.bmBitsPixel
, buffer
);
402 /* Only set entire lines */
403 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
404 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
406 pad
= BITMAP_GetBitsPadding( bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmBitsPixel
);
408 if (!height
|| (pad
== -1))
410 GDI_HEAP_UNLOCK( hbitmap
);
414 sbuf
= (LPBYTE
)buffer
;
416 widthbytes
= DIB_GetXImageWidthBytes(bmp
->bitmap
.bmWidth
,bmp
->bitmap
.bmBitsPixel
);
417 tmpbuffer
= (LPBYTE
)xmalloc(widthbytes
*height
);
419 EnterCriticalSection( &X11DRV_CritSection
);
420 image
= XCreateImage( display
, DefaultVisualOfScreen(screen
),
421 bmp
->bitmap
.bmBitsPixel
, ZPixmap
, 0, tmpbuffer
,
422 bmp
->bitmap
.bmWidth
,height
,32,widthbytes
);
424 /* copy 16 bit padded image buffer with real bitsperpixel to XImage */
425 sbuf
= (LPBYTE
)buffer
;
426 switch (bmp
->bitmap
.bmBitsPixel
)
429 for (h
=0;h
<height
;h
++)
431 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
433 XPutPixel(image
,w
,h
,(sbuf
[0]>>(7-(w
&7))) & 1);
441 for (h
=0;h
<height
;h
++)
443 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
445 if (!(w
& 1)) XPutPixel( image
, w
, h
, *sbuf
>> 4 );
446 else XPutPixel( image
, w
, h
, *sbuf
++ & 0xf );
452 for (h
=0;h
<height
;h
++)
454 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
455 XPutPixel(image
,w
,h
,*sbuf
++);
461 for (h
=0;h
<height
;h
++)
463 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
465 XPutPixel(image
,w
,h
,sbuf
[1]*256+sbuf
[0]);
471 for (h
=0;h
<height
;h
++)
473 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
475 XPutPixel(image
,w
,h
,(sbuf
[2]<<16)+(sbuf
[1]<<8)+sbuf
[0]);
485 descr
.width
= bmp
->bitmap
.bmWidth
;
486 descr
.height
= height
;
487 CALL_LARGE_STACK( XPutImage_wrapper
, &descr
);
488 XDestroyImage( image
); /* frees tmpbuffer too */
489 LeaveCriticalSection( &X11DRV_CritSection
);
491 GDI_HEAP_UNLOCK( hbitmap
);
492 return height
* bmp
->bitmap
.bmWidthBytes
;
495 HANDLE16 WINAPI
LoadImage16( HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
496 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
499 fprintf(stddeb
,"LoadImage16(0x%04x,%s,%d,%d,%d,0x%08x)\n",
500 hinst
,(char *)PTR_SEG_TO_LIN(name
),type
,desiredx
,desiredy
,loadflags
503 fprintf(stddeb
,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
504 hinst
,name
,type
,desiredx
,desiredy
,loadflags
509 return LoadBitmap16(hinst
,name
);
511 return LoadIcon16(hinst
,name
);
513 return LoadCursor16(hinst
,name
);
518 /**********************************************************************
519 * LoadImage32A (USER32.364)
520 * FIXME: implementation still lacks nearly all features, see LR_*
521 * defines in windows.h
524 HANDLE32 WINAPI
LoadImage32A( HINSTANCE32 hinst
, LPCSTR name
, UINT32 type
,
525 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
528 dprintf_resource(stddeb
,"LoadImage32A(0x%04x,%s,%d,%d,%d,0x%08x)\n",
529 hinst
,name
,type
,desiredx
,desiredy
,loadflags
532 dprintf_resource(stddeb
,"LoadImage32A(0x%04x,%p,%d,%d,%d,0x%08x)\n",
533 hinst
,name
,type
,desiredx
,desiredy
,loadflags
538 return LoadBitmap32A(hinst
,name
);
540 return LoadIcon32A(hinst
,name
);
542 return LoadCursor32A(hinst
,name
);
547 HANDLE32 WINAPI
LoadImage32W( HINSTANCE32 hinst
, LPCWSTR name
, UINT32 type
,
548 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
551 dprintf_resource(stddeb
,"LoadImage32W(0x%04x,%p,%d,%d,%d,0x%08x)\n",
552 hinst
,name
,type
,desiredx
,desiredy
,loadflags
555 dprintf_resource(stddeb
,"LoadImage32W(0x%04x,%p,%d,%d,%d,0x%08x)\n",
556 hinst
,name
,type
,desiredx
,desiredy
,loadflags
561 return LoadBitmap32W(hinst
,name
);
563 return LoadIcon32W(hinst
,name
);
565 return LoadCursor32W(hinst
,name
);
570 /**********************************************************************
571 * CopyBitmap32 (not an API)
574 HBITMAP32 WINAPI
CopyBitmap32 (HBITMAP32 hnd
)
579 if (GetObject32A (hnd
, sizeof (bmp
), &bmp
))
581 res
= CreateBitmapIndirect32 (&bmp
);
582 SetBitmapBits32 (res
, bmp
.bmWidthBytes
* bmp
.bmHeight
, bmp
.bmBits
);
587 /**********************************************************************
588 * CopyImage32 (USER32.60)
590 * FIXME: implementation still lacks nearly all features, see LR_*
591 * defines in windows.h
593 HANDLE32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
594 INT32 desiredy
, UINT32 flags
)
599 return CopyBitmap32(hnd
);
601 return CopyIcon32(hnd
);
603 return CopyCursor32(hnd
);
609 /**********************************************************************
610 * LoadBitmap16 (USER.175)
612 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
614 HBITMAP32 hbitmap
= 0;
622 char *str
= (char *)PTR_SEG_TO_LIN( name
);
623 dprintf_bitmap( stddeb
, "LoadBitmap16(%04x,'%s')\n", instance
, str
);
624 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
627 dprintf_bitmap( stddeb
, "LoadBitmap16(%04x,%04x)\n",
628 instance
, LOWORD(name
) );
630 if (!instance
) /* OEM bitmap */
632 if (HIWORD((int)name
)) return 0;
633 return OBM_LoadBitmap( LOWORD((int)name
) );
636 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP
))) return 0;
637 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
639 info
= (BITMAPINFO
*)LockResource16( handle
);
640 if ((hdc
= GetDC32(0)) != 0)
642 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
643 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
644 bits
, info
, DIB_RGB_COLORS
);
645 ReleaseDC32( 0, hdc
);
647 FreeResource16( handle
);
651 /**********************************************************************
652 * LoadBitmap32W (USER32.357)
654 HBITMAP32 WINAPI
LoadBitmap32W( HINSTANCE32 instance
, LPCWSTR name
)
656 HBITMAP32 hbitmap
= 0;
662 if (!instance
) /* OEM bitmap */
664 if (HIWORD((int)name
)) return 0;
665 return OBM_LoadBitmap( LOWORD((int)name
) );
668 if (!(hRsrc
= FindResource32W( instance
, name
,
669 (LPWSTR
)RT_BITMAP
))) return 0;
670 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
672 info
= (BITMAPINFO
*)LockResource32( handle
);
673 if ((hdc
= GetDC32(0)) != 0)
675 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
676 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
677 bits
, info
, DIB_RGB_COLORS
);
678 ReleaseDC32( 0, hdc
);
684 /**********************************************************************
685 * LoadBitmap32A (USER32.356)
687 HBITMAP32 WINAPI
LoadBitmap32A( HINSTANCE32 instance
, LPCSTR name
)
690 if (!HIWORD(name
)) res
= LoadBitmap32W( instance
, (LPWSTR
)name
);
693 LPWSTR uni
= HEAP_strdupAtoW( GetProcessHeap(), 0, name
);
694 res
= LoadBitmap32W( instance
, uni
);
695 HeapFree( GetProcessHeap(), 0, uni
);
701 /***********************************************************************
702 * BITMAP_DeleteObject
704 BOOL32
BITMAP_DeleteObject( HBITMAP16 hbitmap
, BITMAPOBJ
* bmp
)
706 #ifdef PRELIMINARY_WING16_SUPPORT
707 if( bmp
->bitmap
.bmBits
)
708 TSXShmDetach( display
, (XShmSegmentInfo
*)bmp
->bitmap
.bmBits
);
711 TSXFreePixmap( display
, bmp
->pixmap
);
712 #ifdef PRELIMINARY_WING16_SUPPORT
713 if( bmp
->bitmap
.bmBits
)
715 __ShmBitmapCtl
* p
= (__ShmBitmapCtl
*)bmp
->bitmap
.bmBits
;
716 WORD sel
= HIWORD(p
->bits
);
717 unsigned long l
, limit
= GetSelectorLimit(sel
);
719 for( l
= 0; l
< limit
; l
+= 0x10000, sel
+= __AHINCR
)
721 shmctl(p
->si
.shmid
, IPC_RMID
, NULL
);
722 shmdt(p
->si
.shmaddr
); /* already marked for destruction */
725 return GDI_FreeObject( hbitmap
);
729 /***********************************************************************
732 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
734 if (count
> sizeof(bmp
->bitmap
)) count
= sizeof(bmp
->bitmap
);
735 memcpy( buffer
, &bmp
->bitmap
, count
);
740 /***********************************************************************
743 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
746 bmp32
.bmType
= bmp
->bitmap
.bmType
;
747 bmp32
.bmWidth
= bmp
->bitmap
.bmWidth
;
748 bmp32
.bmHeight
= bmp
->bitmap
.bmHeight
;
749 bmp32
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
750 bmp32
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
751 bmp32
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
753 if (count
> sizeof(bmp32
)) count
= sizeof(bmp32
);
754 memcpy( buffer
, &bmp32
, count
);
760 /***********************************************************************
761 * CreateDiscardableBitmap16 (GDI.156)
763 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
766 return CreateCompatibleBitmap16( hdc
, width
, height
);
770 /***********************************************************************
771 * CreateDiscardableBitmap32 (GDI32.38)
773 HBITMAP32 WINAPI
CreateDiscardableBitmap32( HDC32 hdc
, INT32 width
,
776 return CreateCompatibleBitmap32( hdc
, width
, height
);
780 /***********************************************************************
781 * GetBitmapDimensionEx16 (GDI.468)
783 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
785 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
786 if (!bmp
) return FALSE
;
788 GDI_HEAP_UNLOCK( hbitmap
);
793 /***********************************************************************
794 * GetBitmapDimensionEx32 (GDI32.144)
796 BOOL32 WINAPI
GetBitmapDimensionEx32( HBITMAP32 hbitmap
, LPSIZE32 size
)
798 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
799 if (!bmp
) return FALSE
;
800 size
->cx
= (INT32
)bmp
->size
.cx
;
801 size
->cy
= (INT32
)bmp
->size
.cy
;
802 GDI_HEAP_UNLOCK( hbitmap
);
807 /***********************************************************************
808 * GetBitmapDimension (GDI.162)
810 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
813 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
814 return MAKELONG( size
.cx
, size
.cy
);
818 /***********************************************************************
819 * SetBitmapDimensionEx16 (GDI.478)
821 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
824 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
825 if (!bmp
) return FALSE
;
826 if (prevSize
) *prevSize
= bmp
->size
;
829 GDI_HEAP_UNLOCK( hbitmap
);
834 /***********************************************************************
835 * SetBitmapDimensionEx32 (GDI32.304)
837 BOOL32 WINAPI
SetBitmapDimensionEx32( HBITMAP32 hbitmap
, INT32 x
, INT32 y
,
840 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
841 if (!bmp
) return FALSE
;
842 if (prevSize
) CONV_SIZE16TO32( &bmp
->size
, prevSize
);
843 bmp
->size
.cx
= (INT16
)x
;
844 bmp
->size
.cy
= (INT16
)y
;
845 GDI_HEAP_UNLOCK( hbitmap
);
850 /***********************************************************************
851 * SetBitmapDimension (GDI.163)
853 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
856 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
857 return MAKELONG( size
.cx
, size
.cy
);