4 * Copyright 1993 Alexandre Julliard
11 #include <X11/Xutil.h>
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 extern void CLIPPING_UpdateGCRegion( DC
* dc
); /* objects/clipping.c */
32 /***********************************************************************
35 * Wrapper to call XPutImage with CALL_LARGE_STACK.
38 struct XPutImage_descr
46 static int XPutImage_wrapper( const struct XPutImage_descr
*descr
)
48 return XPutImage( display
, descr
->bmp
->pixmap
, BITMAP_GC(descr
->bmp
),
49 descr
->image
, 0, 0, 0, 0, descr
->width
, descr
->height
);
52 /***********************************************************************
53 * BITMAP_GetBitsPadding
55 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
57 INT32
BITMAP_GetBitsPadding( int bmWidth
, int bpp
)
64 if (!(bmWidth
& 15)) pad
= 0;
65 else pad
= ((16 - (bmWidth
& 15)) + 7) / 8;
69 pad
= (2 - (bmWidth
& 1)) & 1;
73 pad
= (bmWidth
*3) & 1;
79 pad
= 0; /* we have 16bit alignment already */
83 if (!(bmWidth
& 3)) pad
= 0;
84 else pad
= ((4 - (bmWidth
& 3)) + 1) / 2;
88 fprintf(stderr
,"GetBitsPadding: unknown depth %d, please report.\n", bpp
);
94 /***********************************************************************
97 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB data.
99 INT32
BITMAP_GetBitsWidth( int bmWidth
, int bpp
)
104 return 2 * ((bmWidth
+15) >> 4);
107 bmWidth
*= 3; /* fall through */
109 return bmWidth
+ (bmWidth
& 1);
119 return 2 * ((bmWidth
+3) >> 2);
122 fprintf(stderr
,"GetBitsPadding: unknown depth %d, please report.\n", bpp
);
127 /***********************************************************************
128 * CreateBitmap16 (GDI.48)
130 HBITMAP16 WINAPI
CreateBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
131 UINT16 bpp
, LPCVOID bits
)
133 return CreateBitmap32( width
, height
, planes
, bpp
, bits
);
137 /***********************************************************************
138 * CreateBitmap32 (GDI32.25)
140 HBITMAP32 WINAPI
CreateBitmap32( INT32 width
, INT32 height
, UINT32 planes
,
141 UINT32 bpp
, LPCVOID bits
)
143 BITMAPOBJ
* bmpObjPtr
;
146 planes
= (BYTE
)planes
;
149 dprintf_gdi( stddeb
, "CreateBitmap: %dx%d, %d colors\n",
150 width
, height
, 1 << (planes
*bpp
) );
152 /* Check parameters */
153 if (!height
|| !width
|| planes
!= 1) return 0;
154 if ((bpp
!= 1) && (bpp
!= screenDepth
)) return 0;
155 if (height
< 0) height
= -height
;
156 if (width
< 0) width
= -width
;
158 /* Create the BITMAPOBJ */
159 hbitmap
= GDI_AllocObject( sizeof(BITMAPOBJ
), BITMAP_MAGIC
);
160 if (!hbitmap
) return 0;
161 bmpObjPtr
= (BITMAPOBJ
*) GDI_HEAP_LOCK( hbitmap
);
163 bmpObjPtr
->size
.cx
= 0;
164 bmpObjPtr
->size
.cy
= 0;
165 bmpObjPtr
->bitmap
.bmType
= 0;
166 bmpObjPtr
->bitmap
.bmWidth
= (INT16
)width
;
167 bmpObjPtr
->bitmap
.bmHeight
= (INT16
)height
;
168 bmpObjPtr
->bitmap
.bmPlanes
= (BYTE
)planes
;
169 bmpObjPtr
->bitmap
.bmBitsPixel
= (BYTE
)bpp
;
170 bmpObjPtr
->bitmap
.bmWidthBytes
= (INT16
)BITMAP_WIDTH_BYTES( width
, bpp
);
171 bmpObjPtr
->bitmap
.bmBits
= NULL
;
173 /* Create the pixmap */
174 bmpObjPtr
->pixmap
= XCreatePixmap(display
, rootWindow
, width
, height
, bpp
);
175 if (!bmpObjPtr
->pixmap
)
177 GDI_HEAP_FREE( hbitmap
);
180 else if (bits
) /* Set bitmap bits */
181 SetBitmapBits32( hbitmap
, height
* bmpObjPtr
->bitmap
.bmWidthBytes
,
183 GDI_HEAP_UNLOCK( hbitmap
);
188 /***********************************************************************
189 * CreateCompatibleBitmap16 (GDI.51)
191 HBITMAP16 WINAPI
CreateCompatibleBitmap16(HDC16 hdc
, INT16 width
, INT16 height
)
193 return CreateCompatibleBitmap32( hdc
, width
, height
);
197 /***********************************************************************
198 * CreateCompatibleBitmap32 (GDI32.30)
200 HBITMAP32 WINAPI
CreateCompatibleBitmap32(HDC32 hdc
, INT32 width
, INT32 height
)
202 HBITMAP32 hbmpRet
= 0;
205 dprintf_gdi( stddeb
, "CreateCompatibleBitmap(%04x,%d,%d) = \n",
206 hdc
, width
, height
);
207 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
208 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
209 dprintf_gdi(stddeb
,"\t\t%04x\n", hbmpRet
);
214 /***********************************************************************
215 * CreateBitmapIndirect16 (GDI.49)
217 HBITMAP16 WINAPI
CreateBitmapIndirect16( const BITMAP16
* bmp
)
219 return CreateBitmap16( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
220 bmp
->bmBitsPixel
, PTR_SEG_TO_LIN( bmp
->bmBits
) );
224 /***********************************************************************
225 * CreateBitmapIndirect32 (GDI32.26)
227 HBITMAP32 WINAPI
CreateBitmapIndirect32( const BITMAP32
* bmp
)
229 return CreateBitmap32( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
230 bmp
->bmBitsPixel
, bmp
->bmBits
);
234 /***********************************************************************
237 * Get an X image for a bitmap. For use with CALL_LARGE_STACK.
239 XImage
*BITMAP_GetXImage( const BITMAPOBJ
*bmp
)
241 return XGetImage( display
, bmp
->pixmap
, 0, 0, bmp
->bitmap
.bmWidth
,
242 bmp
->bitmap
.bmHeight
, AllPlanes
, ZPixmap
);
246 /***********************************************************************
247 * GetBitmapBits16 (GDI.74)
249 LONG WINAPI
GetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPVOID buffer
)
251 return GetBitmapBits32( hbitmap
, count
, buffer
);
255 /***********************************************************************
256 * GetBitmapBits32 (GDI32.143)
258 LONG WINAPI
GetBitmapBits32( HBITMAP32 hbitmap
, LONG count
, LPVOID buffer
)
261 LONG height
, old_height
;
268 fprintf(stderr
, "Negative number of bytes (%ld) passed to GetBitmapBits???\n", count
);
271 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
274 /* Only get entire lines */
275 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
276 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
278 dprintf_bitmap(stddeb
, "GetBitmapBits: %dx%d %d colors %p fetched height: %ld\n",
279 bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
280 1 << bmp
->bitmap
.bmBitsPixel
, buffer
, height
);
282 pad
= BITMAP_GetBitsPadding( bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmBitsPixel
);
284 if (!height
|| (pad
== -1))
286 GDI_HEAP_UNLOCK( hbitmap
);
290 /* Hack: change the bitmap height temporarily to avoid */
291 /* getting unnecessary bitmap rows. */
292 old_height
= bmp
->bitmap
.bmHeight
;
293 bmp
->bitmap
.bmHeight
= height
;
294 image
= (XImage
*)CALL_LARGE_STACK( BITMAP_GetXImage
, bmp
);
295 bmp
->bitmap
.bmHeight
= old_height
;
297 /* copy XImage to 16 bit padded image buffer with real bitsperpixel */
300 switch (bmp
->bitmap
.bmBitsPixel
)
303 for (h
=0;h
<height
;h
++)
306 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
310 *tbuf
|= XGetPixel(image
,w
,h
)<<(7-(w
&7));
311 if ((w
&7) == 7) ++tbuf
;
317 for (h
=0;h
<height
;h
++)
319 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
321 if (!(w
& 1)) *tbuf
= XGetPixel( image
, w
, h
) << 4;
322 else *tbuf
++ |= XGetPixel( image
, w
, h
) & 0x0f;
328 for (h
=0;h
<height
;h
++)
330 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
331 *tbuf
++ = XGetPixel(image
,w
,h
);
337 for (h
=0;h
<height
;h
++)
339 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
341 long pixel
= XGetPixel(image
,w
,h
);
343 *tbuf
++ = pixel
& 0xff;
344 *tbuf
++ = (pixel
>>8) & 0xff;
349 for (h
=0;h
<height
;h
++)
351 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
353 long pixel
= XGetPixel(image
,w
,h
);
355 *tbuf
++ = pixel
& 0xff;
356 *tbuf
++ = (pixel
>> 8) & 0xff;
357 *tbuf
++ = (pixel
>>16) & 0xff;
362 XDestroyImage( image
);
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_bitmap(stddeb
, "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
);
417 image
= XCreateImage( display
, DefaultVisualOfScreen(screen
),
418 bmp
->bitmap
.bmBitsPixel
, ZPixmap
, 0, tmpbuffer
,
419 bmp
->bitmap
.bmWidth
,height
,32,widthbytes
422 /* copy 16 bit padded image buffer with real bitsperpixel to XImage */
423 sbuf
= (LPBYTE
)buffer
;
424 switch (bmp
->bitmap
.bmBitsPixel
)
427 for (h
=0;h
<height
;h
++)
429 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
431 XPutPixel(image
,w
,h
,(sbuf
[0]>>(7-(w
&7))) & 1);
439 for (h
=0;h
<height
;h
++)
441 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
443 if (!(w
& 1)) XPutPixel( image
, w
, h
, *sbuf
>> 4 );
444 else XPutPixel( image
, w
, h
, *sbuf
++ & 0xf );
450 for (h
=0;h
<height
;h
++)
452 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
453 XPutPixel(image
,w
,h
,*sbuf
++);
459 for (h
=0;h
<height
;h
++)
461 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
463 XPutPixel(image
,w
,h
,sbuf
[1]*256+sbuf
[0]);
469 for (h
=0;h
<height
;h
++)
471 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
473 XPutPixel(image
,w
,h
,(sbuf
[2]<<16)+(sbuf
[1]<<8)+sbuf
[0]);
483 descr
.width
= bmp
->bitmap
.bmWidth
;
484 descr
.height
= height
;
485 CALL_LARGE_STACK( XPutImage_wrapper
, &descr
);
487 XDestroyImage( image
); /* frees tmpbuffer too */
488 GDI_HEAP_UNLOCK( hbitmap
);
489 return height
* bmp
->bitmap
.bmWidthBytes
;
492 HANDLE16 WINAPI
LoadImage16( HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
493 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
496 fprintf(stddeb
,"LoadImage16(0x%04x,%s,%d,%d,%d,0x%08x)\n",
497 hinst
,(char *)PTR_SEG_TO_LIN(name
),type
,desiredx
,desiredy
,loadflags
500 fprintf(stddeb
,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
501 hinst
,name
,type
,desiredx
,desiredy
,loadflags
506 return LoadBitmap16(hinst
,name
);
508 return LoadIcon16(hinst
,name
);
510 return LoadCursor16(hinst
,name
);
515 /**********************************************************************
516 * LoadImageA (USER32.364)
517 * FIXME: implementation still lacks nearly all features, see LR_*
518 * defines in windows.h
521 HANDLE32 WINAPI
LoadImage32A( HINSTANCE32 hinst
, LPCSTR name
, UINT32 type
,
522 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
525 dprintf_resource(stddeb
,"LoadImage32A(0x%04x,%s,%d,%d,%d,0x%08x)\n",
526 hinst
,name
,type
,desiredx
,desiredy
,loadflags
529 dprintf_resource(stddeb
,"LoadImage32A(0x%04x,%p,%d,%d,%d,0x%08x)\n",
530 hinst
,name
,type
,desiredx
,desiredy
,loadflags
535 return LoadBitmap32A(hinst
,name
);
537 return LoadIcon32A(hinst
,name
);
539 return LoadCursor32A(hinst
,name
);
544 HANDLE32 WINAPI
LoadImage32W( HINSTANCE32 hinst
, LPCWSTR name
, UINT32 type
,
545 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
548 dprintf_resource(stddeb
,"LoadImage32W(0x%04x,%p,%d,%d,%d,0x%08x)\n",
549 hinst
,name
,type
,desiredx
,desiredy
,loadflags
552 dprintf_resource(stddeb
,"LoadImage32W(0x%04x,%p,%d,%d,%d,0x%08x)\n",
553 hinst
,name
,type
,desiredx
,desiredy
,loadflags
558 return LoadBitmap32W(hinst
,name
);
560 return LoadIcon32W(hinst
,name
);
562 return LoadCursor32W(hinst
,name
);
567 /**********************************************************************
568 * CopyBitmap32 (not an API)
571 HBITMAP32 WINAPI
CopyBitmap32 (HBITMAP32 hnd
)
576 if (GetObject32A (hnd
, sizeof (bmp
), &bmp
))
578 res
= CreateBitmapIndirect32 (&bmp
);
579 SetBitmapBits32 (res
, bmp
.bmWidthBytes
* bmp
.bmHeight
, bmp
.bmBits
);
584 /**********************************************************************
585 * CopyImage32 (USER32.60)
587 * FIXME: implementation still lacks nearly all features, see LR_*
588 * defines in windows.h
590 HANDLE32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
591 INT32 desiredy
, UINT32 flags
)
596 return CopyBitmap32(hnd
);
598 return CopyIcon32(hnd
);
600 return CopyCursor32(hnd
);
606 /**********************************************************************
607 * LoadBitmap16 (USER.175)
609 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
611 HBITMAP32 hbitmap
= 0;
619 char *str
= (char *)PTR_SEG_TO_LIN( name
);
620 dprintf_bitmap( stddeb
, "LoadBitmap16(%04x,'%s')\n", instance
, str
);
621 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
624 dprintf_bitmap( stddeb
, "LoadBitmap16(%04x,%04x)\n",
625 instance
, LOWORD(name
) );
627 if (!instance
) /* OEM bitmap */
629 if (HIWORD((int)name
)) return 0;
630 return OBM_LoadBitmap( LOWORD((int)name
) );
633 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP
))) return 0;
634 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
636 info
= (BITMAPINFO
*)LockResource16( handle
);
637 if ((hdc
= GetDC32(0)) != 0)
639 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
640 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
641 bits
, info
, DIB_RGB_COLORS
);
642 ReleaseDC32( 0, hdc
);
644 FreeResource16( handle
);
648 /**********************************************************************
649 * LoadBitmap32W (USER32.357)
651 HBITMAP32 WINAPI
LoadBitmap32W( HINSTANCE32 instance
, LPCWSTR name
)
653 HBITMAP32 hbitmap
= 0;
659 if (!instance
) /* OEM bitmap */
661 if (HIWORD((int)name
)) return 0;
662 return OBM_LoadBitmap( LOWORD((int)name
) );
665 if (!(hRsrc
= FindResource32W( instance
, name
,
666 (LPWSTR
)RT_BITMAP
))) return 0;
667 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
669 info
= (BITMAPINFO
*)LockResource32( handle
);
670 if ((hdc
= GetDC32(0)) != 0)
672 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
673 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
674 bits
, info
, DIB_RGB_COLORS
);
675 ReleaseDC32( 0, hdc
);
681 /**********************************************************************
682 * LoadBitmap32A (USER32.356)
684 HBITMAP32 WINAPI
LoadBitmap32A( HINSTANCE32 instance
, LPCSTR name
)
687 if (!HIWORD(name
)) res
= LoadBitmap32W( instance
, (LPWSTR
)name
);
690 LPWSTR uni
= HEAP_strdupAtoW( GetProcessHeap(), 0, name
);
691 res
= LoadBitmap32W( instance
, uni
);
692 HeapFree( GetProcessHeap(), 0, uni
);
698 /***********************************************************************
699 * BITMAP_DeleteObject
701 BOOL32
BITMAP_DeleteObject( HBITMAP16 hbitmap
, BITMAPOBJ
* bmp
)
703 #ifdef PRELIMINARY_WING16_SUPPORT
704 if( bmp
->bitmap
.bmBits
)
705 XShmDetach( display
, (XShmSegmentInfo
*)bmp
->bitmap
.bmBits
);
708 XFreePixmap( display
, bmp
->pixmap
);
709 #ifdef PRELIMINARY_WING16_SUPPORT
710 if( bmp
->bitmap
.bmBits
)
712 __ShmBitmapCtl
* p
= (__ShmBitmapCtl
*)bmp
->bitmap
.bmBits
;
713 WORD sel
= HIWORD(p
->bits
);
714 unsigned long l
, limit
= GetSelectorLimit(sel
);
716 for( l
= 0; l
< limit
; l
+= 0x10000, sel
+= __AHINCR
)
718 shmctl(p
->si
.shmid
, IPC_RMID
, NULL
);
719 shmdt(p
->si
.shmaddr
); /* already marked for destruction */
722 return GDI_FreeObject( hbitmap
);
726 /***********************************************************************
729 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
731 if (count
> sizeof(bmp
->bitmap
)) count
= sizeof(bmp
->bitmap
);
732 memcpy( buffer
, &bmp
->bitmap
, count
);
737 /***********************************************************************
740 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
743 bmp32
.bmType
= bmp
->bitmap
.bmType
;
744 bmp32
.bmWidth
= bmp
->bitmap
.bmWidth
;
745 bmp32
.bmHeight
= bmp
->bitmap
.bmHeight
;
746 bmp32
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
747 bmp32
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
748 bmp32
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
750 if (count
> sizeof(bmp32
)) count
= sizeof(bmp32
);
751 memcpy( buffer
, &bmp32
, count
);
757 /***********************************************************************
758 * CreateDiscardableBitmap16 (GDI.156)
760 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
763 return CreateCompatibleBitmap16( hdc
, width
, height
);
767 /***********************************************************************
768 * CreateDiscardableBitmap32 (GDI32.38)
770 HBITMAP32 WINAPI
CreateDiscardableBitmap32( HDC32 hdc
, INT32 width
,
773 return CreateCompatibleBitmap32( hdc
, width
, height
);
777 /***********************************************************************
778 * GetBitmapDimensionEx16 (GDI.468)
780 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
782 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
783 if (!bmp
) return FALSE
;
785 GDI_HEAP_UNLOCK( hbitmap
);
790 /***********************************************************************
791 * GetBitmapDimensionEx32 (GDI32.144)
793 BOOL32 WINAPI
GetBitmapDimensionEx32( HBITMAP32 hbitmap
, LPSIZE32 size
)
795 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
796 if (!bmp
) return FALSE
;
797 size
->cx
= (INT32
)bmp
->size
.cx
;
798 size
->cy
= (INT32
)bmp
->size
.cy
;
799 GDI_HEAP_UNLOCK( hbitmap
);
804 /***********************************************************************
805 * GetBitmapDimension (GDI.162)
807 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
810 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
811 return MAKELONG( size
.cx
, size
.cy
);
815 /***********************************************************************
816 * SetBitmapDimensionEx16 (GDI.478)
818 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
821 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
822 if (!bmp
) return FALSE
;
823 if (prevSize
) *prevSize
= bmp
->size
;
826 GDI_HEAP_UNLOCK( hbitmap
);
831 /***********************************************************************
832 * SetBitmapDimensionEx32 (GDI32.304)
834 BOOL32 WINAPI
SetBitmapDimensionEx32( HBITMAP32 hbitmap
, INT32 x
, INT32 y
,
837 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
838 if (!bmp
) return FALSE
;
839 if (prevSize
) CONV_SIZE16TO32( &bmp
->size
, prevSize
);
840 bmp
->size
.cx
= (INT16
)x
;
841 bmp
->size
.cy
= (INT16
)y
;
842 GDI_HEAP_UNLOCK( hbitmap
);
847 /***********************************************************************
848 * SetBitmapDimension (GDI.163)
850 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
853 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
854 return MAKELONG( size
.cx
, size
.cy
);