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 WARN(bitmap
,"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 WARN(bitmap
,"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] Creates a bitmap with the specified info
137 * width [I] bitmap width
138 * height [I] bitmap height
139 * planes [I] Number of color planes
140 * bpp [I] Number of bits to identify a color
141 * bits [I] Pointer to array containing color data
144 * Success: Handle to bitmap
147 HBITMAP32 WINAPI
CreateBitmap32( INT32 width
, INT32 height
, UINT32 planes
,
148 UINT32 bpp
, LPCVOID bits
)
150 BITMAPOBJ
* bmpObjPtr
;
153 planes
= (BYTE
)planes
;
156 TRACE(gdi
, "%dx%d, %d colors\n", width
, height
, 1 << (planes
*bpp
) );
158 /* Check parameters */
159 if (!height
|| !width
|| planes
!= 1) return 0;
160 if ((bpp
!= 1) && (bpp
!= screenDepth
)) return 0;
161 if (height
< 0) height
= -height
;
162 if (width
< 0) width
= -width
;
164 /* Create the BITMAPOBJ */
165 hbitmap
= GDI_AllocObject( sizeof(BITMAPOBJ
), BITMAP_MAGIC
);
166 if (!hbitmap
) return 0;
167 bmpObjPtr
= (BITMAPOBJ
*) GDI_HEAP_LOCK( hbitmap
);
169 bmpObjPtr
->size
.cx
= 0;
170 bmpObjPtr
->size
.cy
= 0;
171 bmpObjPtr
->bitmap
.bmType
= 0;
172 bmpObjPtr
->bitmap
.bmWidth
= (INT16
)width
;
173 bmpObjPtr
->bitmap
.bmHeight
= (INT16
)height
;
174 bmpObjPtr
->bitmap
.bmPlanes
= (BYTE
)planes
;
175 bmpObjPtr
->bitmap
.bmBitsPixel
= (BYTE
)bpp
;
176 bmpObjPtr
->bitmap
.bmWidthBytes
= (INT16
)BITMAP_WIDTH_BYTES( width
, bpp
);
177 bmpObjPtr
->bitmap
.bmBits
= NULL
;
179 /* Create the pixmap */
180 bmpObjPtr
->pixmap
= TSXCreatePixmap(display
, rootWindow
, width
, height
, bpp
);
181 if (!bmpObjPtr
->pixmap
)
183 GDI_HEAP_FREE( hbitmap
);
186 else if (bits
) /* Set bitmap bits */
187 SetBitmapBits32( hbitmap
, height
* bmpObjPtr
->bitmap
.bmWidthBytes
,
189 GDI_HEAP_UNLOCK( hbitmap
);
194 /***********************************************************************
195 * CreateCompatibleBitmap16 (GDI.51)
197 HBITMAP16 WINAPI
CreateCompatibleBitmap16(HDC16 hdc
, INT16 width
, INT16 height
)
199 return CreateCompatibleBitmap32( hdc
, width
, height
);
203 /******************************************************************************
204 * CreateCompatibleBitmap32 [GDI32.30] Creates a bitmap compatible with the DC
207 * hdc [I] Handle to device context
208 * width [I] Width of bitmap
209 * height [I] Height of bitmap
212 * Success: Handle to bitmap
215 HBITMAP32 WINAPI
CreateCompatibleBitmap32( HDC32 hdc
, INT32 width
, INT32 height
)
217 HBITMAP32 hbmpRet
= 0;
220 TRACE(gdi
, "(%04x,%d,%d) = \n", hdc
, width
, height
);
221 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
222 if ((width
>0x1000) || (height
> 0x1000))
224 FIXME(gdi
,"got bad width %d or height %d, please look for reason\n",
228 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
229 TRACE(gdi
,"\t\t%04x\n", hbmpRet
);
234 /***********************************************************************
235 * CreateBitmapIndirect16 (GDI.49)
237 HBITMAP16 WINAPI
CreateBitmapIndirect16( const BITMAP16
* bmp
)
239 return CreateBitmap16( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
240 bmp
->bmBitsPixel
, PTR_SEG_TO_LIN( bmp
->bmBits
) );
244 /******************************************************************************
245 * CreateBitmapIndirect32 [GDI32.26] Creates a bitmap with the specifies info
248 * Success: Handle to bitmap
251 HBITMAP32 WINAPI
CreateBitmapIndirect32(
252 const BITMAP32
* bmp
) /* [in] Pointer to the bitmap data */
254 return CreateBitmap32( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
255 bmp
->bmBitsPixel
, bmp
->bmBits
);
259 /***********************************************************************
262 * Get an X image for a bitmap. For use with CALL_LARGE_STACK.
264 XImage
*BITMAP_GetXImage( const BITMAPOBJ
*bmp
)
266 return XGetImage( display
, bmp
->pixmap
, 0, 0, bmp
->bitmap
.bmWidth
,
267 bmp
->bitmap
.bmHeight
, AllPlanes
, ZPixmap
);
271 /***********************************************************************
272 * GetBitmapBits16 (GDI.74)
274 LONG WINAPI
GetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPVOID buffer
)
276 return GetBitmapBits32( hbitmap
, count
, buffer
);
280 /***********************************************************************
281 * GetBitmapBits32 [GDI32.143] Copies bitmap bits of bitmap to buffer
284 * Success: Number of bytes copied
287 LONG WINAPI
GetBitmapBits32(
288 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
289 LONG count
, /* [in] Number of bytes to copy */
290 LPVOID buffer
) /* [out] Pointer to buffer to receive bits */
293 LONG height
, old_height
;
300 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
303 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
306 /* Only get entire lines */
307 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
308 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
310 TRACE(bitmap
, "%dx%d %d colors %p fetched height: %ld\n",
311 bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
312 1 << bmp
->bitmap
.bmBitsPixel
, buffer
, height
);
314 pad
= BITMAP_GetBitsPadding( bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmBitsPixel
);
316 if (!height
|| (pad
== -1))
318 GDI_HEAP_UNLOCK( hbitmap
);
322 EnterCriticalSection( &X11DRV_CritSection
);
324 /* Hack: change the bitmap height temporarily to avoid */
325 /* getting unnecessary bitmap rows. */
326 old_height
= bmp
->bitmap
.bmHeight
;
327 bmp
->bitmap
.bmHeight
= height
;
328 image
= (XImage
*)CALL_LARGE_STACK( BITMAP_GetXImage
, bmp
);
329 bmp
->bitmap
.bmHeight
= old_height
;
331 /* copy XImage to 16 bit padded image buffer with real bitsperpixel */
334 switch (bmp
->bitmap
.bmBitsPixel
)
337 for (h
=0;h
<height
;h
++)
340 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
344 *tbuf
|= XGetPixel(image
,w
,h
)<<(7-(w
&7));
345 if ((w
&7) == 7) ++tbuf
;
351 for (h
=0;h
<height
;h
++)
353 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
355 if (!(w
& 1)) *tbuf
= XGetPixel( image
, w
, h
) << 4;
356 else *tbuf
++ |= XGetPixel( image
, w
, h
) & 0x0f;
362 for (h
=0;h
<height
;h
++)
364 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
365 *tbuf
++ = XGetPixel(image
,w
,h
);
371 for (h
=0;h
<height
;h
++)
373 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
375 long pixel
= XGetPixel(image
,w
,h
);
377 *tbuf
++ = pixel
& 0xff;
378 *tbuf
++ = (pixel
>>8) & 0xff;
383 for (h
=0;h
<height
;h
++)
385 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
387 long pixel
= XGetPixel(image
,w
,h
);
389 *tbuf
++ = pixel
& 0xff;
390 *tbuf
++ = (pixel
>> 8) & 0xff;
391 *tbuf
++ = (pixel
>>16) & 0xff;
397 FIXME(bitmap
, "Unhandled bits:%d\n", bmp
->bitmap
.bmBitsPixel
);
399 XDestroyImage( image
);
400 LeaveCriticalSection( &X11DRV_CritSection
);
402 GDI_HEAP_UNLOCK( hbitmap
);
403 return height
* bmp
->bitmap
.bmWidthBytes
;
407 /***********************************************************************
408 * SetBitmapBits16 (GDI.106)
410 LONG WINAPI
SetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPCVOID buffer
)
412 return SetBitmapBits32( hbitmap
, count
, buffer
);
416 /******************************************************************************
417 * SetBitmapBits32 [GDI32.303] Sets bits of color data for a bitmap
420 * Success: Number of bytes used in setting the bitmap bits
423 LONG WINAPI
SetBitmapBits32(
424 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
425 LONG count
, /* [in] Number of bytes in bitmap array */
426 LPCVOID buffer
) /* [in] Address of array with bitmap bits */
428 struct XPutImage_descr descr
;
432 LPBYTE sbuf
,tmpbuffer
;
433 int w
,h
,pad
,widthbytes
;
437 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
440 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
443 TRACE(bitmap
, "%dx%d %d colors %p\n",
444 bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
445 1 << bmp
->bitmap
.bmBitsPixel
, buffer
);
447 /* Only set entire lines */
448 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
449 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
451 pad
= BITMAP_GetBitsPadding( bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmBitsPixel
);
453 if (!height
|| (pad
== -1))
455 GDI_HEAP_UNLOCK( hbitmap
);
459 sbuf
= (LPBYTE
)buffer
;
461 widthbytes
= DIB_GetXImageWidthBytes(bmp
->bitmap
.bmWidth
,bmp
->bitmap
.bmBitsPixel
);
462 tmpbuffer
= (LPBYTE
)xmalloc(widthbytes
*height
);
464 EnterCriticalSection( &X11DRV_CritSection
);
465 image
= XCreateImage( display
, DefaultVisualOfScreen(screen
),
466 bmp
->bitmap
.bmBitsPixel
, ZPixmap
, 0, tmpbuffer
,
467 bmp
->bitmap
.bmWidth
,height
,32,widthbytes
);
469 /* copy 16 bit padded image buffer with real bitsperpixel to XImage */
470 sbuf
= (LPBYTE
)buffer
;
471 switch (bmp
->bitmap
.bmBitsPixel
)
474 for (h
=0;h
<height
;h
++)
476 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
478 XPutPixel(image
,w
,h
,(sbuf
[0]>>(7-(w
&7))) & 1);
486 for (h
=0;h
<height
;h
++)
488 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
490 if (!(w
& 1)) XPutPixel( image
, w
, h
, *sbuf
>> 4 );
491 else XPutPixel( image
, w
, h
, *sbuf
++ & 0xf );
497 for (h
=0;h
<height
;h
++)
499 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
500 XPutPixel(image
,w
,h
,*sbuf
++);
506 for (h
=0;h
<height
;h
++)
508 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
510 XPutPixel(image
,w
,h
,sbuf
[1]*256+sbuf
[0]);
516 for (h
=0;h
<height
;h
++)
518 for (w
=0;w
<bmp
->bitmap
.bmWidth
;w
++)
520 XPutPixel(image
,w
,h
,(sbuf
[2]<<16)+(sbuf
[1]<<8)+sbuf
[0]);
530 descr
.width
= bmp
->bitmap
.bmWidth
;
531 descr
.height
= height
;
532 CALL_LARGE_STACK( XPutImage_wrapper
, &descr
);
533 XDestroyImage( image
); /* frees tmpbuffer too */
534 LeaveCriticalSection( &X11DRV_CritSection
);
536 GDI_HEAP_UNLOCK( hbitmap
);
537 return height
* bmp
->bitmap
.bmWidthBytes
;
540 /***********************************************************************
541 * LoadImage16 [USER.389]
544 HANDLE16 WINAPI
LoadImage16( HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
545 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
548 TRACE(resource
,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
549 hinst
,(char *)PTR_SEG_TO_LIN(name
),type
,desiredx
,desiredy
,loadflags
);
551 TRACE(resource
,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
552 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
556 return LoadBitmap16(hinst
,(SEGPTR
)name
);
558 return LoadIcon16(hinst
,(SEGPTR
)name
);
560 return LoadCursor16(hinst
,(SEGPTR
)name
);
566 /**********************************************************************
567 * LoadImage32A (USER32.365)
569 * FIXME: implementation still lacks nearly all features, see LR_*
570 * defines in windows.h
573 HANDLE32 WINAPI
LoadImage32A( HINSTANCE32 hinst
, LPCSTR name
, UINT32 type
,
574 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
577 TRACE(resource
,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
578 hinst
,name
,type
,desiredx
,desiredy
,loadflags
581 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
582 hinst
,name
,type
,desiredx
,desiredy
,loadflags
587 return LoadBitmap32A(hinst
,name
);
589 return LoadIcon32A(hinst
,name
);
591 return LoadCursor32A(hinst
,name
);
596 /**********************************************************************
597 * LoadImage32W (USER32.366)
599 * FIXME: implementation still lacks nearly all features, see LR_*
600 * defines in windows.h
604 /******************************************************************************
605 * LoadImage32W [USER32.366] Loads an icon, cursor, or bitmap
608 * hinst [I] Handle of instance that contains image
609 * name [I] Name of image
610 * type [I] Type of image
611 * desiredx [I] Desired width
612 * desiredy [I] Desired height
613 * loadflags [I] Load flags
616 * Success: Handle to newly loaded image
620 * Implementation still lacks nearly all features, see LR_*
621 * defines in windows.h
623 HANDLE32 WINAPI
LoadImage32W( HINSTANCE32 hinst
, LPCWSTR name
, UINT32 type
,
624 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
627 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
628 hinst
,name
,type
,desiredx
,desiredy
,loadflags
631 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
632 hinst
,name
,type
,desiredx
,desiredy
,loadflags
638 return LoadBitmap32W(hinst
,name
);
640 return LoadIcon32W(hinst
,name
);
642 return LoadCursor32W(hinst
,name
);
648 /**********************************************************************
649 * CopyBitmap32 (not an API)
652 * If it is not an API, why is it declared with WINAPI?
655 HBITMAP32 WINAPI
CopyBitmap32 (HBITMAP32 hnd
)
660 if (GetObject32A (hnd
, sizeof (bmp
), &bmp
))
662 res
= CreateBitmapIndirect32 (&bmp
);
663 SetBitmapBits32 (res
, bmp
.bmWidthBytes
* bmp
.bmHeight
, bmp
.bmBits
);
669 /******************************************************************************
670 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
673 * hnd [I] Handle to image to copy
674 * type [I] Type of image to copy
675 * desiredx [I] Desired width of new image
676 * desiredy [I] Desired height of new image
677 * flags [I] Copy flags
680 * Success: Handle to newly created image
683 * FIXME: implementation still lacks nearly all features, see LR_*
684 * defines in windows.h
686 HANDLE32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
687 INT32 desiredy
, UINT32 flags
)
692 return CopyBitmap32(hnd
);
694 return CopyIcon32(hnd
);
696 return CopyCursor32(hnd
);
702 /**********************************************************************
703 * LoadBitmap16 (USER.175)
706 * Can this call LoadBitmap32?
708 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
710 HBITMAP32 hbitmap
= 0;
718 char *str
= (char *)PTR_SEG_TO_LIN( name
);
719 TRACE(bitmap
, "(%04x,'%s')\n", instance
, str
);
720 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
723 TRACE(bitmap
, "(%04x,%04x)\n",
724 instance
, LOWORD(name
) );
726 if (!instance
) /* OEM bitmap */
728 if (HIWORD((int)name
)) return 0;
729 return OBM_LoadBitmap( LOWORD((int)name
) );
732 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP16
))) return 0;
733 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
735 info
= (BITMAPINFO
*)LockResource16( handle
);
736 if ((hdc
= GetDC32(0)) != 0)
738 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
739 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
740 bits
, info
, DIB_RGB_COLORS
);
741 ReleaseDC32( 0, hdc
);
743 FreeResource16( handle
);
748 /******************************************************************************
749 * LoadBitmap32W [USER32.358] Loads bitmap from the executable file
752 * Success: Handle to specified bitmap
755 HBITMAP32 WINAPI
LoadBitmap32W(
756 HINSTANCE32 instance
, /* [in] Handle to application instance */
757 LPCWSTR name
) /* [in] Address of bitmap resource name */
759 HBITMAP32 hbitmap
= 0;
765 if (!instance
) /* OEM bitmap */
767 if (HIWORD((int)name
)) return 0;
768 return OBM_LoadBitmap( LOWORD((int)name
) );
771 if (!(hRsrc
= FindResource32W( instance
, name
, RT_BITMAP32W
))) return 0;
772 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
774 info
= (BITMAPINFO
*)LockResource32( handle
);
775 if ((hdc
= GetDC32(0)) != 0)
777 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
778 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
779 bits
, info
, DIB_RGB_COLORS
);
780 ReleaseDC32( 0, hdc
);
786 /**********************************************************************
787 * LoadBitmap32A (USER32.357)
789 HBITMAP32 WINAPI
LoadBitmap32A( HINSTANCE32 instance
, LPCSTR name
)
792 if (!HIWORD(name
)) res
= LoadBitmap32W( instance
, (LPWSTR
)name
);
795 LPWSTR uni
= HEAP_strdupAtoW( GetProcessHeap(), 0, name
);
796 res
= LoadBitmap32W( instance
, uni
);
797 HeapFree( GetProcessHeap(), 0, uni
);
803 /***********************************************************************
804 * BITMAP_DeleteObject
806 BOOL32
BITMAP_DeleteObject( HBITMAP16 hbitmap
, BITMAPOBJ
* bmp
)
808 #ifdef PRELIMINARY_WING16_SUPPORT
809 if( bmp
->bitmap
.bmBits
)
810 TSXShmDetach( display
, (XShmSegmentInfo
*)bmp
->bitmap
.bmBits
);
813 TSXFreePixmap( display
, bmp
->pixmap
);
814 #ifdef PRELIMINARY_WING16_SUPPORT
815 if( bmp
->bitmap
.bmBits
)
817 __ShmBitmapCtl
* p
= (__ShmBitmapCtl
*)bmp
->bitmap
.bmBits
;
818 WORD sel
= HIWORD(p
->bits
);
819 unsigned long l
, limit
= GetSelectorLimit(sel
);
821 for( l
= 0; l
< limit
; l
+= 0x10000, sel
+= __AHINCR
)
823 shmctl(p
->si
.shmid
, IPC_RMID
, NULL
);
824 shmdt(p
->si
.shmaddr
); /* already marked for destruction */
827 return GDI_FreeObject( hbitmap
);
831 /***********************************************************************
834 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
836 if (count
> sizeof(bmp
->bitmap
)) count
= sizeof(bmp
->bitmap
);
837 memcpy( buffer
, &bmp
->bitmap
, count
);
842 /***********************************************************************
845 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
848 bmp32
.bmType
= bmp
->bitmap
.bmType
;
849 bmp32
.bmWidth
= bmp
->bitmap
.bmWidth
;
850 bmp32
.bmHeight
= bmp
->bitmap
.bmHeight
;
851 bmp32
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
852 bmp32
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
853 bmp32
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
855 if (count
> sizeof(bmp32
)) count
= sizeof(bmp32
);
856 memcpy( buffer
, &bmp32
, count
);
861 /***********************************************************************
862 * CreateDiscardableBitmap16 (GDI.156)
864 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
867 return CreateCompatibleBitmap16( hdc
, width
, height
);
871 /******************************************************************************
872 * CreateDiscardableBitmap32 [GDI32.38] Creates a discardable bitmap
875 * Success: Handle to bitmap
878 HBITMAP32 WINAPI
CreateDiscardableBitmap32(
879 HDC32 hdc
, /* [in] Handle to device context */
880 INT32 width
, /* [in] Bitmap width */
881 INT32 height
) /* [in] Bitmap height */
883 return CreateCompatibleBitmap32( hdc
, width
, height
);
887 /***********************************************************************
888 * GetBitmapDimensionEx16 (GDI.468)
891 * Can this call GetBitmapDimensionEx32?
893 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
895 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
896 if (!bmp
) return FALSE
;
898 GDI_HEAP_UNLOCK( hbitmap
);
903 /******************************************************************************
904 * GetBitmapDimensionEx32 [GDI32.144] Retrieves dimensions of a bitmap
910 BOOL32 WINAPI
GetBitmapDimensionEx32(
911 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
912 LPSIZE32 size
) /* [out] Address of struct receiving dimensions */
914 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
915 if (!bmp
) return FALSE
;
916 size
->cx
= (INT32
)bmp
->size
.cx
;
917 size
->cy
= (INT32
)bmp
->size
.cy
;
918 GDI_HEAP_UNLOCK( hbitmap
);
923 /***********************************************************************
924 * GetBitmapDimension (GDI.162)
926 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
929 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
930 return MAKELONG( size
.cx
, size
.cy
);
934 /***********************************************************************
935 * SetBitmapDimensionEx16 (GDI.478)
937 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
940 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
941 if (!bmp
) return FALSE
;
942 if (prevSize
) *prevSize
= bmp
->size
;
945 GDI_HEAP_UNLOCK( hbitmap
);
950 /******************************************************************************
951 * SetBitmapDimensionEx32 [GDI32.304] Assignes dimensions to a bitmap
957 BOOL32 WINAPI
SetBitmapDimensionEx32(
958 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
959 INT32 x
, /* [in] Bitmap width */
960 INT32 y
, /* [in] Bitmap height */
961 LPSIZE32 prevSize
) /* [out] Address of structure for orig dims */
963 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
964 if (!bmp
) return FALSE
;
965 if (prevSize
) CONV_SIZE16TO32( &bmp
->size
, prevSize
);
966 bmp
->size
.cx
= (INT16
)x
;
967 bmp
->size
.cy
= (INT16
)y
;
968 GDI_HEAP_UNLOCK( hbitmap
);
973 /***********************************************************************
974 * SetBitmapDimension (GDI.163)
976 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
979 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
980 return MAKELONG( size
.cx
, size
.cy
);