4 * Copyright 1993 Alexandre Julliard
19 #ifdef PRELIMINARY_WING16_SUPPORT
20 #include <sys/types.h>
25 /* GCs used for B&W and color bitmap operations */
26 GC BITMAP_monoGC
= 0, BITMAP_colorGC
= 0;
28 /***********************************************************************
31 * Wrapper to call XPutImage with CALL_LARGE_STACK.
34 struct XPutImage_descr
42 static int XPutImage_wrapper( const struct XPutImage_descr
*descr
)
44 return XPutImage( display
, descr
->bmp
->pixmap
, BITMAP_GC(descr
->bmp
),
45 descr
->image
, 0, 0, 0, 0, descr
->width
, descr
->height
);
48 /***********************************************************************
49 * BITMAP_GetBitsPadding
51 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
53 INT32
BITMAP_GetBitsPadding( int bmWidth
, int bpp
)
60 if (!(bmWidth
& 15)) pad
= 0;
61 else pad
= ((16 - (bmWidth
& 15)) + 7) / 8;
65 pad
= (2 - (bmWidth
& 1)) & 1;
69 pad
= (bmWidth
*3) & 1;
75 pad
= 0; /* we have 16bit alignment already */
79 if (!(bmWidth
& 3)) pad
= 0;
80 else pad
= ((4 - (bmWidth
& 3)) + 1) / 2;
84 fprintf(stderr
,"GetBitsPadding: unknown depth %d, please report.\n", bpp
);
90 /***********************************************************************
93 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB data.
95 INT32
BITMAP_GetBitsWidth( int bmWidth
, int bpp
)
100 return 2 * ((bmWidth
+15) >> 4);
103 bmWidth
*= 3; /* fall through */
105 return bmWidth
+ (bmWidth
& 1);
115 return 2 * ((bmWidth
+3) >> 2);
118 fprintf(stderr
,"GetBitsPadding: unknown depth %d, please report.\n", bpp
);
123 /***********************************************************************
124 * CreateBitmap16 (GDI.48)
126 HBITMAP16 WINAPI
CreateBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
127 UINT16 bpp
, LPCVOID bits
)
129 return CreateBitmap32( width
, height
, planes
, bpp
, bits
);
133 /***********************************************************************
134 * CreateBitmap32 (GDI32.25)
136 HBITMAP32 WINAPI
CreateBitmap32( INT32 width
, INT32 height
, UINT32 planes
,
137 UINT32 bpp
, LPCVOID bits
)
139 BITMAPOBJ
* bmpObjPtr
;
142 planes
= (BYTE
)planes
;
145 dprintf_info(gdi
, "CreateBitmap: %dx%d, %d colors\n",
146 width
, height
, 1 << (planes
*bpp
) );
148 /* Check parameters */
149 if (!height
|| !width
|| planes
!= 1) return 0;
150 if ((bpp
!= 1) && (bpp
!= screenDepth
)) return 0;
151 if (height
< 0) height
= -height
;
152 if (width
< 0) width
= -width
;
154 /* Create the BITMAPOBJ */
155 hbitmap
= GDI_AllocObject( sizeof(BITMAPOBJ
), BITMAP_MAGIC
);
156 if (!hbitmap
) return 0;
157 bmpObjPtr
= (BITMAPOBJ
*) GDI_HEAP_LOCK( hbitmap
);
159 bmpObjPtr
->size
.cx
= 0;
160 bmpObjPtr
->size
.cy
= 0;
161 bmpObjPtr
->bitmap
.bmType
= 0;
162 bmpObjPtr
->bitmap
.bmWidth
= (INT16
)width
;
163 bmpObjPtr
->bitmap
.bmHeight
= (INT16
)height
;
164 bmpObjPtr
->bitmap
.bmPlanes
= (BYTE
)planes
;
165 bmpObjPtr
->bitmap
.bmBitsPixel
= (BYTE
)bpp
;
166 bmpObjPtr
->bitmap
.bmWidthBytes
= (INT16
)BITMAP_WIDTH_BYTES( width
, bpp
);
167 bmpObjPtr
->bitmap
.bmBits
= NULL
;
169 /* Create the pixmap */
170 bmpObjPtr
->pixmap
= TSXCreatePixmap(display
, rootWindow
, width
, height
, bpp
);
171 if (!bmpObjPtr
->pixmap
)
173 GDI_HEAP_FREE( hbitmap
);
176 else if (bits
) /* Set bitmap bits */
177 SetBitmapBits32( hbitmap
, height
* bmpObjPtr
->bitmap
.bmWidthBytes
,
179 GDI_HEAP_UNLOCK( hbitmap
);
184 /***********************************************************************
185 * CreateCompatibleBitmap16 (GDI.51)
187 HBITMAP16 WINAPI
CreateCompatibleBitmap16(HDC16 hdc
, INT16 width
, INT16 height
)
189 return CreateCompatibleBitmap32( hdc
, width
, height
);
193 /***********************************************************************
194 * CreateCompatibleBitmap32 (GDI32.30)
196 HBITMAP32 WINAPI
CreateCompatibleBitmap32(HDC32 hdc
, INT32 width
, INT32 height
)
198 HBITMAP32 hbmpRet
= 0;
201 dprintf_info(gdi
, "CreateCompatibleBitmap(%04x,%d,%d) = \n",
202 hdc
, width
, height
);
203 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
204 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
205 dprintf_info(gdi
,"\t\t%04x\n", hbmpRet
);
210 /***********************************************************************
211 * CreateBitmapIndirect16 (GDI.49)
213 HBITMAP16 WINAPI
CreateBitmapIndirect16( const BITMAP16
* bmp
)
215 return CreateBitmap16( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
216 bmp
->bmBitsPixel
, PTR_SEG_TO_LIN( bmp
->bmBits
) );
220 /***********************************************************************
221 * CreateBitmapIndirect32 (GDI32.26)
223 HBITMAP32 WINAPI
CreateBitmapIndirect32( const BITMAP32
* bmp
)
225 return CreateBitmap32( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
226 bmp
->bmBitsPixel
, bmp
->bmBits
);
230 /***********************************************************************
233 * Get an X image for a bitmap. For use with CALL_LARGE_STACK.
235 XImage
*BITMAP_GetXImage( const BITMAPOBJ
*bmp
)
237 return XGetImage( display
, bmp
->pixmap
, 0, 0, bmp
->bitmap
.bmWidth
,
238 bmp
->bitmap
.bmHeight
, AllPlanes
, ZPixmap
);
242 /***********************************************************************
243 * GetBitmapBits16 (GDI.74)
245 LONG WINAPI
GetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPVOID buffer
)
247 return GetBitmapBits32( hbitmap
, count
, buffer
);
251 /***********************************************************************
252 * GetBitmapBits32 (GDI32.143)
254 LONG WINAPI
GetBitmapBits32( HBITMAP32 hbitmap
, LONG count
, LPVOID buffer
)
257 LONG height
, old_height
;
264 fprintf(stderr
, "Negative number of bytes (%ld) passed to GetBitmapBits???\n", count
);
267 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
270 /* Only get entire lines */
271 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
272 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
274 dprintf_info(bitmap
, "GetBitmapBits: %dx%d %d colors %p fetched height: %ld\n",
275 bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
276 1 << bmp
->bitmap
.bmBitsPixel
, buffer
, height
);
278 pad
= BITMAP_GetBitsPadding( bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmBitsPixel
);
280 if (!height
|| (pad
== -1))
282 GDI_HEAP_UNLOCK( hbitmap
);
286 EnterCriticalSection( &X11DRV_CritSection
);
288 /* Hack: change the bitmap height temporarily to avoid */
289 /* getting unnecessary bitmap rows. */
290 old_height
= bmp
->bitmap
.bmHeight
;
291 bmp
->bitmap
.bmHeight
= height
;
292 image
= (XImage
*)CALL_LARGE_STACK( BITMAP_GetXImage
, bmp
);
293 bmp
->bitmap
.bmHeight
= old_height
;
295 /* copy XImage to 16 bit padded image buffer with real bitsperpixel */
298 switch (bmp
->bitmap
.bmBitsPixel
)
301 for (h
=0;h
<height
;h
++)
304 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
308 *tbuf
|= XGetPixel(image
,w
,h
)<<(7-(w
&7));
309 if ((w
&7) == 7) ++tbuf
;
315 for (h
=0;h
<height
;h
++)
317 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
319 if (!(w
& 1)) *tbuf
= XGetPixel( image
, w
, h
) << 4;
320 else *tbuf
++ |= XGetPixel( image
, w
, h
) & 0x0f;
326 for (h
=0;h
<height
;h
++)
328 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
329 *tbuf
++ = XGetPixel(image
,w
,h
);
335 for (h
=0;h
<height
;h
++)
337 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
339 long pixel
= XGetPixel(image
,w
,h
);
341 *tbuf
++ = pixel
& 0xff;
342 *tbuf
++ = (pixel
>>8) & 0xff;
347 for (h
=0;h
<height
;h
++)
349 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
351 long pixel
= XGetPixel(image
,w
,h
);
353 *tbuf
++ = pixel
& 0xff;
354 *tbuf
++ = (pixel
>> 8) & 0xff;
355 *tbuf
++ = (pixel
>>16) & 0xff;
360 XDestroyImage( image
);
361 LeaveCriticalSection( &X11DRV_CritSection
);
363 GDI_HEAP_UNLOCK( hbitmap
);
364 return height
* bmp
->bitmap
.bmWidthBytes
;
368 /***********************************************************************
369 * SetBitmapBits16 (GDI.106)
371 LONG WINAPI
SetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPCVOID buffer
)
373 return SetBitmapBits32( hbitmap
, count
, buffer
);
377 /***********************************************************************
378 * SetBitmapBits32 (GDI32.303)
380 LONG WINAPI
SetBitmapBits32( HBITMAP32 hbitmap
, LONG count
, LPCVOID buffer
)
382 struct XPutImage_descr descr
;
386 LPBYTE sbuf
,tmpbuffer
;
387 int w
,h
,pad
,widthbytes
;
391 fprintf(stderr
, "Negative number of bytes (%ld) passed to SetBitmapBits???\n", count
);
394 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
397 dprintf_info(bitmap
, "SetBitmapBits: %dx%d %d colors %p\n",
398 bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
399 1 << bmp
->bitmap
.bmBitsPixel
, buffer
);
401 /* Only set entire lines */
402 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
403 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
405 pad
= BITMAP_GetBitsPadding( bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmBitsPixel
);
407 if (!height
|| (pad
== -1))
409 GDI_HEAP_UNLOCK( hbitmap
);
413 sbuf
= (LPBYTE
)buffer
;
415 widthbytes
= DIB_GetXImageWidthBytes(bmp
->bitmap
.bmWidth
,bmp
->bitmap
.bmBitsPixel
);
416 tmpbuffer
= (LPBYTE
)xmalloc(widthbytes
*height
);
418 EnterCriticalSection( &X11DRV_CritSection
);
419 image
= XCreateImage( display
, DefaultVisualOfScreen(screen
),
420 bmp
->bitmap
.bmBitsPixel
, ZPixmap
, 0, tmpbuffer
,
421 bmp
->bitmap
.bmWidth
,height
,32,widthbytes
);
423 /* copy 16 bit padded image buffer with real bitsperpixel to XImage */
424 sbuf
= (LPBYTE
)buffer
;
425 switch (bmp
->bitmap
.bmBitsPixel
)
428 for (h
=0;h
<height
;h
++)
430 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
432 XPutPixel(image
,w
,h
,(sbuf
[0]>>(7-(w
&7))) & 1);
440 for (h
=0;h
<height
;h
++)
442 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
444 if (!(w
& 1)) XPutPixel( image
, w
, h
, *sbuf
>> 4 );
445 else XPutPixel( image
, w
, h
, *sbuf
++ & 0xf );
451 for (h
=0;h
<height
;h
++)
453 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
454 XPutPixel(image
,w
,h
,*sbuf
++);
460 for (h
=0;h
<height
;h
++)
462 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
464 XPutPixel(image
,w
,h
,sbuf
[1]*256+sbuf
[0]);
470 for (h
=0;h
<height
;h
++)
472 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
474 XPutPixel(image
,w
,h
,(sbuf
[2]<<16)+(sbuf
[1]<<8)+sbuf
[0]);
484 descr
.width
= bmp
->bitmap
.bmWidth
;
485 descr
.height
= height
;
486 CALL_LARGE_STACK( XPutImage_wrapper
, &descr
);
487 XDestroyImage( image
); /* frees tmpbuffer too */
488 LeaveCriticalSection( &X11DRV_CritSection
);
490 GDI_HEAP_UNLOCK( hbitmap
);
491 return height
* bmp
->bitmap
.bmWidthBytes
;
494 HANDLE16 WINAPI
LoadImage16( HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
495 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
498 fprintf(stddeb
,"LoadImage16(0x%04x,%s,%d,%d,%d,0x%08x)\n",
499 hinst
,(char *)PTR_SEG_TO_LIN(name
),type
,desiredx
,desiredy
,loadflags
502 fprintf(stddeb
,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
503 hinst
,name
,type
,desiredx
,desiredy
,loadflags
508 return LoadBitmap16(hinst
,(SEGPTR
)name
);
510 return LoadIcon16(hinst
,(SEGPTR
)name
);
512 return LoadCursor16(hinst
,(SEGPTR
)name
);
517 /**********************************************************************
518 * LoadImage32A (USER32.364)
519 * FIXME: implementation still lacks nearly all features, see LR_*
520 * defines in windows.h
523 HANDLE32 WINAPI
LoadImage32A( HINSTANCE32 hinst
, LPCSTR name
, UINT32 type
,
524 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
527 dprintf_info(resource
,"LoadImage32A(0x%04x,%s,%d,%d,%d,0x%08x)\n",
528 hinst
,name
,type
,desiredx
,desiredy
,loadflags
531 dprintf_info(resource
,"LoadImage32A(0x%04x,%p,%d,%d,%d,0x%08x)\n",
532 hinst
,name
,type
,desiredx
,desiredy
,loadflags
537 return LoadBitmap32A(hinst
,name
);
539 return LoadIcon32A(hinst
,name
);
541 return LoadCursor32A(hinst
,name
);
546 HANDLE32 WINAPI
LoadImage32W( HINSTANCE32 hinst
, LPCWSTR name
, UINT32 type
,
547 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
550 dprintf_info(resource
,"LoadImage32W(0x%04x,%p,%d,%d,%d,0x%08x)\n",
551 hinst
,name
,type
,desiredx
,desiredy
,loadflags
554 dprintf_info(resource
,"LoadImage32W(0x%04x,%p,%d,%d,%d,0x%08x)\n",
555 hinst
,name
,type
,desiredx
,desiredy
,loadflags
560 return LoadBitmap32W(hinst
,name
);
562 return LoadIcon32W(hinst
,name
);
564 return LoadCursor32W(hinst
,name
);
569 /**********************************************************************
570 * CopyBitmap32 (not an API)
573 HBITMAP32 WINAPI
CopyBitmap32 (HBITMAP32 hnd
)
578 if (GetObject32A (hnd
, sizeof (bmp
), &bmp
))
580 res
= CreateBitmapIndirect32 (&bmp
);
581 SetBitmapBits32 (res
, bmp
.bmWidthBytes
* bmp
.bmHeight
, bmp
.bmBits
);
586 /**********************************************************************
587 * CopyImage32 (USER32.60)
589 * FIXME: implementation still lacks nearly all features, see LR_*
590 * defines in windows.h
592 HANDLE32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
593 INT32 desiredy
, UINT32 flags
)
598 return CopyBitmap32(hnd
);
600 return CopyIcon32(hnd
);
602 return CopyCursor32(hnd
);
608 /**********************************************************************
609 * LoadBitmap16 (USER.175)
611 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
613 HBITMAP32 hbitmap
= 0;
621 char *str
= (char *)PTR_SEG_TO_LIN( name
);
622 dprintf_info(bitmap
, "LoadBitmap16(%04x,'%s')\n", instance
, str
);
623 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
626 dprintf_info(bitmap
, "LoadBitmap16(%04x,%04x)\n",
627 instance
, LOWORD(name
) );
629 if (!instance
) /* OEM bitmap */
631 if (HIWORD((int)name
)) return 0;
632 return OBM_LoadBitmap( LOWORD((int)name
) );
635 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP
))) return 0;
636 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
638 info
= (BITMAPINFO
*)LockResource16( handle
);
639 if ((hdc
= GetDC32(0)) != 0)
641 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
642 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
643 bits
, info
, DIB_RGB_COLORS
);
644 ReleaseDC32( 0, hdc
);
646 FreeResource16( handle
);
650 /**********************************************************************
651 * LoadBitmap32W (USER32.357)
653 HBITMAP32 WINAPI
LoadBitmap32W( HINSTANCE32 instance
, LPCWSTR name
)
655 HBITMAP32 hbitmap
= 0;
661 if (!instance
) /* OEM bitmap */
663 if (HIWORD((int)name
)) return 0;
664 return OBM_LoadBitmap( LOWORD((int)name
) );
667 if (!(hRsrc
= FindResource32W( instance
, name
,
668 (LPWSTR
)RT_BITMAP
))) return 0;
669 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
671 info
= (BITMAPINFO
*)LockResource32( handle
);
672 if ((hdc
= GetDC32(0)) != 0)
674 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
675 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
676 bits
, info
, DIB_RGB_COLORS
);
677 ReleaseDC32( 0, hdc
);
683 /**********************************************************************
684 * LoadBitmap32A (USER32.356)
686 HBITMAP32 WINAPI
LoadBitmap32A( HINSTANCE32 instance
, LPCSTR name
)
689 if (!HIWORD(name
)) res
= LoadBitmap32W( instance
, (LPWSTR
)name
);
692 LPWSTR uni
= HEAP_strdupAtoW( GetProcessHeap(), 0, name
);
693 res
= LoadBitmap32W( instance
, uni
);
694 HeapFree( GetProcessHeap(), 0, uni
);
700 /***********************************************************************
701 * BITMAP_DeleteObject
703 BOOL32
BITMAP_DeleteObject( HBITMAP16 hbitmap
, BITMAPOBJ
* bmp
)
705 #ifdef PRELIMINARY_WING16_SUPPORT
706 if( bmp
->bitmap
.bmBits
)
707 TSXShmDetach( display
, (XShmSegmentInfo
*)bmp
->bitmap
.bmBits
);
710 TSXFreePixmap( display
, bmp
->pixmap
);
711 #ifdef PRELIMINARY_WING16_SUPPORT
712 if( bmp
->bitmap
.bmBits
)
714 __ShmBitmapCtl
* p
= (__ShmBitmapCtl
*)bmp
->bitmap
.bmBits
;
715 WORD sel
= HIWORD(p
->bits
);
716 unsigned long l
, limit
= GetSelectorLimit(sel
);
718 for( l
= 0; l
< limit
; l
+= 0x10000, sel
+= __AHINCR
)
720 shmctl(p
->si
.shmid
, IPC_RMID
, NULL
);
721 shmdt(p
->si
.shmaddr
); /* already marked for destruction */
724 return GDI_FreeObject( hbitmap
);
728 /***********************************************************************
731 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
733 if (count
> sizeof(bmp
->bitmap
)) count
= sizeof(bmp
->bitmap
);
734 memcpy( buffer
, &bmp
->bitmap
, count
);
739 /***********************************************************************
742 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
745 bmp32
.bmType
= bmp
->bitmap
.bmType
;
746 bmp32
.bmWidth
= bmp
->bitmap
.bmWidth
;
747 bmp32
.bmHeight
= bmp
->bitmap
.bmHeight
;
748 bmp32
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
749 bmp32
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
750 bmp32
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
752 if (count
> sizeof(bmp32
)) count
= sizeof(bmp32
);
753 memcpy( buffer
, &bmp32
, count
);
759 /***********************************************************************
760 * CreateDiscardableBitmap16 (GDI.156)
762 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
765 return CreateCompatibleBitmap16( hdc
, width
, height
);
769 /***********************************************************************
770 * CreateDiscardableBitmap32 (GDI32.38)
772 HBITMAP32 WINAPI
CreateDiscardableBitmap32( HDC32 hdc
, INT32 width
,
775 return CreateCompatibleBitmap32( hdc
, width
, height
);
779 /***********************************************************************
780 * GetBitmapDimensionEx16 (GDI.468)
782 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
784 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
785 if (!bmp
) return FALSE
;
787 GDI_HEAP_UNLOCK( hbitmap
);
792 /***********************************************************************
793 * GetBitmapDimensionEx32 (GDI32.144)
795 BOOL32 WINAPI
GetBitmapDimensionEx32( HBITMAP32 hbitmap
, LPSIZE32 size
)
797 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
798 if (!bmp
) return FALSE
;
799 size
->cx
= (INT32
)bmp
->size
.cx
;
800 size
->cy
= (INT32
)bmp
->size
.cy
;
801 GDI_HEAP_UNLOCK( hbitmap
);
806 /***********************************************************************
807 * GetBitmapDimension (GDI.162)
809 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
812 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
813 return MAKELONG( size
.cx
, size
.cy
);
817 /***********************************************************************
818 * SetBitmapDimensionEx16 (GDI.478)
820 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
823 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
824 if (!bmp
) return FALSE
;
825 if (prevSize
) *prevSize
= bmp
->size
;
828 GDI_HEAP_UNLOCK( hbitmap
);
833 /***********************************************************************
834 * SetBitmapDimensionEx32 (GDI32.304)
836 BOOL32 WINAPI
SetBitmapDimensionEx32( HBITMAP32 hbitmap
, INT32 x
, INT32 y
,
839 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
840 if (!bmp
) return FALSE
;
841 if (prevSize
) CONV_SIZE16TO32( &bmp
->size
, prevSize
);
842 bmp
->size
.cx
= (INT16
)x
;
843 bmp
->size
.cy
= (INT16
)y
;
844 GDI_HEAP_UNLOCK( hbitmap
);
849 /***********************************************************************
850 * SetBitmapDimension (GDI.163)
852 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
855 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
856 return MAKELONG( size
.cx
, size
.cy
);