4 * Copyright 1993 Alexandre Julliard
15 #include "sysmetrics.h"
16 #include "cursoricon.h"
20 /***********************************************************************
23 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
25 INT32
BITMAP_GetPadding( int bmWidth
, int bpp
)
32 pad
= ((bmWidth
-1) & 8) ? 0 : 1;
36 pad
= (2 - (bmWidth
& 1)) & 1;
40 pad
= (bmWidth
*3) & 1;
46 pad
= 0; /* we have 16bit alignment already */
50 if (!(bmWidth
& 3)) pad
= 0;
51 else pad
= ((4 - (bmWidth
& 3)) + 1) / 2;
55 WARN(bitmap
,"Unknown depth %d, please report.\n", bpp
);
61 /***********************************************************************
62 * BITMAP_GetWidthBytes
64 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
67 INT32
BITMAP_GetWidthBytes( INT32 bmWidth
, INT32 bpp
)
72 return 2 * ((bmWidth
+15) >> 4);
75 bmWidth
*= 3; /* fall through */
77 return bmWidth
+ (bmWidth
& 1);
87 return 2 * ((bmWidth
+3) >> 2);
90 WARN(bitmap
,"Unknown depth %d, please report.\n", bpp
);
95 /***********************************************************************
96 * CreateUserBitmap16 (GDI.407)
98 HBITMAP16 WINAPI
CreateUserBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
99 UINT16 bpp
, LPCVOID bits
)
101 return CreateBitmap16( width
, height
, planes
, bpp
, bits
);
104 /***********************************************************************
105 * CreateUserDiscardableBitmap16 (GDI.409)
107 HBITMAP16 WINAPI
CreateUserDiscardableBitmap16( WORD dummy
,
108 INT16 width
, INT16 height
)
110 return CreateUserBitmap16( width
, height
, 1, screenDepth
, NULL
);
114 /***********************************************************************
115 * CreateBitmap16 (GDI.48)
117 HBITMAP16 WINAPI
CreateBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
118 UINT16 bpp
, LPCVOID bits
)
120 return CreateBitmap32( width
, height
, planes
, bpp
, bits
);
124 /******************************************************************************
125 * CreateBitmap32 [GDI32.25] Creates a bitmap with the specified info
128 * width [I] bitmap width
129 * height [I] bitmap height
130 * planes [I] Number of color planes
131 * bpp [I] Number of bits to identify a color
132 * bits [I] Pointer to array containing color data
135 * Success: Handle to bitmap
138 HBITMAP32 WINAPI
CreateBitmap32( INT32 width
, INT32 height
, UINT32 planes
,
139 UINT32 bpp
, LPCVOID bits
)
144 planes
= (BYTE
)planes
;
148 /* Check parameters */
149 if (!height
|| !width
) return 0;
151 FIXME(bitmap
, "planes = %d\n", planes
);
154 if (height
< 0) height
= -height
;
155 if (width
< 0) width
= -width
;
157 /* Create the BITMAPOBJ */
158 hbitmap
= GDI_AllocObject( sizeof(BITMAPOBJ
), BITMAP_MAGIC
);
159 if (!hbitmap
) return 0;
161 TRACE(bitmap
, "%dx%d, %d colors returning %08x\n", width
, height
,
162 1 << (planes
*bpp
), hbitmap
);
164 bmp
= (BITMAPOBJ
*) GDI_HEAP_LOCK( hbitmap
);
168 bmp
->bitmap
.bmType
= 0;
169 bmp
->bitmap
.bmWidth
= width
;
170 bmp
->bitmap
.bmHeight
= height
;
171 bmp
->bitmap
.bmPlanes
= planes
;
172 bmp
->bitmap
.bmBitsPixel
= bpp
;
173 bmp
->bitmap
.bmWidthBytes
= BITMAP_GetWidthBytes( width
, bpp
);
174 bmp
->bitmap
.bmBits
= NULL
;
176 bmp
->DDBitmap
= NULL
;
179 if (bits
) /* Set bitmap bits */
180 SetBitmapBits32( hbitmap
, height
* bmp
->bitmap
.bmWidthBytes
,
182 GDI_HEAP_UNLOCK( hbitmap
);
187 /***********************************************************************
188 * CreateCompatibleBitmap16 (GDI.51)
190 HBITMAP16 WINAPI
CreateCompatibleBitmap16(HDC16 hdc
, INT16 width
, INT16 height
)
192 return CreateCompatibleBitmap32( hdc
, width
, height
);
196 /******************************************************************************
197 * CreateCompatibleBitmap32 [GDI32.30] Creates a bitmap compatible with the DC
200 * hdc [I] Handle to device context
201 * width [I] Width of bitmap
202 * height [I] Height of bitmap
205 * Success: Handle to bitmap
208 HBITMAP32 WINAPI
CreateCompatibleBitmap32( HDC32 hdc
, INT32 width
, INT32 height
)
210 HBITMAP32 hbmpRet
= 0;
213 TRACE(bitmap
, "(%04x,%d,%d) = \n", hdc
, width
, height
);
214 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
215 if ((width
>0x1000) || (height
> 0x1000)) {
216 FIXME(bitmap
,"got bad width %d or height %d, please look for reason\n",
220 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
222 if(dc
->funcs
->pCreateBitmap
)
223 dc
->funcs
->pCreateBitmap( hbmpRet
);
225 TRACE(bitmap
,"\t\t%04x\n", hbmpRet
);
230 /***********************************************************************
231 * CreateBitmapIndirect16 (GDI.49)
233 HBITMAP16 WINAPI
CreateBitmapIndirect16( const BITMAP16
* bmp
)
235 return CreateBitmap16( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
236 bmp
->bmBitsPixel
, PTR_SEG_TO_LIN( bmp
->bmBits
) );
240 /******************************************************************************
241 * CreateBitmapIndirect32 [GDI32.26] Creates a bitmap with the specifies info
244 * Success: Handle to bitmap
247 HBITMAP32 WINAPI
CreateBitmapIndirect32(
248 const BITMAP32
* bmp
) /* [in] Pointer to the bitmap data */
250 return CreateBitmap32( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
251 bmp
->bmBitsPixel
, bmp
->bmBits
);
255 /***********************************************************************
256 * GetBitmapBits16 (GDI.74)
258 LONG WINAPI
GetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPVOID buffer
)
260 return GetBitmapBits32( hbitmap
, count
, buffer
);
264 /***********************************************************************
265 * GetBitmapBits32 [GDI32.143] Copies bitmap bits of bitmap to buffer
268 * Success: Number of bytes copied
271 LONG WINAPI
GetBitmapBits32(
272 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
273 LONG count
, /* [in] Number of bytes to copy */
274 LPVOID bits
) /* [out] Pointer to buffer to receive bits */
276 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
282 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
286 /* Only get entire lines */
287 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
288 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
289 count
= height
* bmp
->bitmap
.bmWidthBytes
;
292 WARN(bitmap
, "Less then one entire line requested\n");
293 GDI_HEAP_UNLOCK( hbitmap
);
298 TRACE(bitmap
, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
299 hbitmap
, count
, bits
, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
300 1 << bmp
->bitmap
.bmBitsPixel
, height
);
304 TRACE(bitmap
, "Calling device specific BitmapBits\n");
305 if(bmp
->DDBitmap
->funcs
->pBitmapBits
)
306 ret
= bmp
->DDBitmap
->funcs
->pBitmapBits(hbitmap
, bits
, count
,
309 ERR(bitmap
, "BitmapBits == NULL??\n");
315 if(!bmp
->bitmap
.bmBits
) {
316 WARN(bitmap
, "Bitmap is empty\n");
319 memcpy(bits
, bmp
->bitmap
.bmBits
, count
);
325 GDI_HEAP_UNLOCK( hbitmap
);
330 /***********************************************************************
331 * SetBitmapBits16 (GDI.106)
333 LONG WINAPI
SetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPCVOID buffer
)
335 return SetBitmapBits32( hbitmap
, count
, buffer
);
339 /******************************************************************************
340 * SetBitmapBits32 [GDI32.303] Sets bits of color data for a bitmap
343 * Success: Number of bytes used in setting the bitmap bits
346 LONG WINAPI
SetBitmapBits32(
347 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
348 LONG count
, /* [in] Number of bytes in bitmap array */
349 LPCVOID bits
) /* [in] Address of array with bitmap bits */
351 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
357 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
361 /* Only get entire lines */
362 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
363 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
364 count
= height
* bmp
->bitmap
.bmWidthBytes
;
366 TRACE(bitmap
, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
367 hbitmap
, count
, bits
, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
368 1 << bmp
->bitmap
.bmBitsPixel
, height
);
372 TRACE(bitmap
, "Calling device specific BitmapBits\n");
373 if(bmp
->DDBitmap
->funcs
->pBitmapBits
)
374 ret
= bmp
->DDBitmap
->funcs
->pBitmapBits(hbitmap
, (void *) bits
,
377 ERR(bitmap
, "BitmapBits == NULL??\n");
383 if(!bmp
->bitmap
.bmBits
) /* Alloc enough for entire bitmap */
384 bmp
->bitmap
.bmBits
= HeapAlloc( GetProcessHeap(), 0, count
);
385 if(!bmp
->bitmap
.bmBits
) {
386 WARN(bitmap
, "Unable to allocate bit buffer\n");
389 memcpy(bmp
->bitmap
.bmBits
, bits
, count
);
394 GDI_HEAP_UNLOCK( hbitmap
);
398 /***********************************************************************
399 * LoadImage16 [USER.389]
402 HANDLE16 WINAPI
LoadImage16( HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
403 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
406 TRACE(resource
,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
407 hinst
,(char *)PTR_SEG_TO_LIN(name
),type
,desiredx
,desiredy
,loadflags
);
409 TRACE(resource
,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
410 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
414 return LoadBitmap16(hinst
,(SEGPTR
)name
);
416 return LoadIcon16(hinst
,(SEGPTR
)name
);
418 return LoadCursor16(hinst
,(SEGPTR
)name
);
424 /**********************************************************************
425 * LoadImage32A (USER32.365)
427 * FIXME: implementation lacks some features, see LR_ defines in windows.h
430 HANDLE32 WINAPI
LoadImage32A( HINSTANCE32 hinst
, LPCSTR name
, UINT32 type
,
431 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
436 if (HIWORD(name
)) u_name
= HEAP_strdupAtoW(GetProcessHeap(), 0, name
);
437 else u_name
=(LPWSTR
)name
;
438 res
= LoadImage32W(hinst
, u_name
, type
, desiredx
, desiredy
, loadflags
);
439 if (HIWORD(name
)) HeapFree(GetProcessHeap(), 0, u_name
);
444 /******************************************************************************
445 * LoadImage32W [USER32.366] Loads an icon, cursor, or bitmap
448 * hinst [I] Handle of instance that contains image
449 * name [I] Name of image
450 * type [I] Type of image
451 * desiredx [I] Desired width
452 * desiredy [I] Desired height
453 * loadflags [I] Load flags
456 * Success: Handle to newly loaded image
459 * FIXME: Implementation lacks some features, see LR_ defines in windows.h
461 HANDLE32 WINAPI
LoadImage32W( HINSTANCE32 hinst
, LPCWSTR name
, UINT32 type
,
462 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
465 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
466 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
468 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
469 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
471 if (loadflags
& LR_DEFAULTSIZE
) {
472 if (type
== IMAGE_ICON
) {
473 if (!desiredx
) desiredx
= SYSMETRICS_CXICON
;
474 if (!desiredy
) desiredy
= SYSMETRICS_CYICON
;
475 } else if (type
== IMAGE_CURSOR
) {
476 if (!desiredx
) desiredx
= SYSMETRICS_CXCURSOR
;
477 if (!desiredy
) desiredy
= SYSMETRICS_CYCURSOR
;
480 if (loadflags
& LR_LOADFROMFILE
) loadflags
&= ~LR_SHARED
;
483 return BITMAP_LoadBitmap32W(hinst
, name
, loadflags
);
487 HDC32 hdc
= GetDC32(0);
488 UINT32 palEnts
= GetSystemPaletteEntries32(hdc
, 0, 0, NULL
);
491 return CURSORICON_Load32(hinst
, name
, desiredx
, desiredy
,
492 MIN(16, palEnts
), FALSE
, loadflags
);
496 return CURSORICON_Load32(hinst
, name
, desiredx
, desiredy
,
503 /**********************************************************************
507 HBITMAP32
BITMAP_CopyBitmap(HBITMAP32 hbitmap
)
509 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
517 res
= CreateBitmapIndirect32(&bm
);
520 char *buf
= HeapAlloc( GetProcessHeap(), 0, bm
.bmWidthBytes
*
522 GetBitmapBits32 (hbitmap
, bm
.bmWidthBytes
* bm
.bmHeight
, buf
);
523 SetBitmapBits32 (res
, bm
.bmWidthBytes
* bm
.bmHeight
, buf
);
524 HeapFree( GetProcessHeap(), 0, buf
);
527 GDI_HEAP_UNLOCK( hbitmap
);
532 /******************************************************************************
533 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
536 * hnd [I] Handle to image to copy
537 * type [I] Type of image to copy
538 * desiredx [I] Desired width of new image
539 * desiredy [I] Desired height of new image
540 * flags [I] Copy flags
543 * Success: Handle to newly created image
546 * FIXME: implementation still lacks nearly all features, see LR_*
547 * defines in windows.h
549 HICON32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
550 INT32 desiredy
, UINT32 flags
)
555 return BITMAP_CopyBitmap(hnd
);
557 return CopyIcon32(hnd
);
559 return CopyCursor32(hnd
);
564 /**********************************************************************
565 * LoadBitmap16 (USER.175)
568 * Can this call LoadBitmap32?
570 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
572 HBITMAP32 hbitmap
= 0;
580 char *str
= (char *)PTR_SEG_TO_LIN( name
);
581 TRACE(bitmap
, "(%04x,'%s')\n", instance
, str
);
582 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
585 TRACE(bitmap
, "(%04x,%04x)\n",
586 instance
, LOWORD(name
) );
588 if (!instance
) /* OEM bitmap */
590 if (HIWORD((int)name
)) return 0;
591 return OBM_LoadBitmap( LOWORD((int)name
) );
594 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP16
))) return 0;
595 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
597 info
= (BITMAPINFO
*)LockResource16( handle
);
598 if ((hdc
= GetDC32(0)) != 0)
600 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
601 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
602 bits
, info
, DIB_RGB_COLORS
);
603 ReleaseDC32( 0, hdc
);
605 FreeResource16( handle
);
610 /**********************************************************************
611 * BITMAP_LoadBitmap32W
613 HBITMAP32
BITMAP_LoadBitmap32W(HINSTANCE32 instance
,LPCWSTR name
,
616 HBITMAP32 hbitmap
= 0;
621 BITMAPINFO
*info
, *fix_info
=NULL
;
625 if (!(loadflags
& LR_LOADFROMFILE
)) {
626 if (!instance
) /* OEM bitmap */
628 if (HIWORD((int)name
)) return 0;
629 return OBM_LoadBitmap( LOWORD((int)name
) );
632 if (!(hRsrc
= FindResource32W( instance
, name
, RT_BITMAP32W
))) return 0;
633 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
635 if ((info
= (BITMAPINFO
*)LockResource32( handle
)) == NULL
) return 0;
639 if (!(ptr
= (char *)VIRTUAL_MapFileW( name
))) return 0;
640 info
= (BITMAPINFO
*)(ptr
+ sizeof(BITMAPFILEHEADER
));
642 size
= DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
);
643 if ((hFix
= GlobalAlloc32(0, size
))) fix_info
=GlobalLock32(hFix
);
647 memcpy(fix_info
, info
, size
);
648 pix
= *((LPBYTE
)info
+DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
));
649 DIB_FixColorsToLoadflags(fix_info
, loadflags
, pix
);
650 if ((hdc
= GetDC32(0)) != 0) {
651 if (loadflags
& LR_CREATEDIBSECTION
)
652 hbitmap
= CreateDIBSection32(hdc
, fix_info
, DIB_RGB_COLORS
, NULL
, 0, 0);
654 char *bits
= (char *)info
+ size
;;
655 hbitmap
= CreateDIBitmap32( hdc
, &fix_info
->bmiHeader
, CBM_INIT
,
656 bits
, fix_info
, DIB_RGB_COLORS
);
658 ReleaseDC32( 0, hdc
);
660 GlobalUnlock32(hFix
);
663 if (loadflags
& LR_LOADFROMFILE
) UnmapViewOfFile( ptr
);
668 /******************************************************************************
669 * LoadBitmap32W [USER32.358] Loads bitmap from the executable file
672 * Success: Handle to specified bitmap
675 HBITMAP32 WINAPI
LoadBitmap32W(
676 HINSTANCE32 instance
, /* [in] Handle to application instance */
677 LPCWSTR name
) /* [in] Address of bitmap resource name */
679 return BITMAP_LoadBitmap32W(instance
, name
, 0);
683 /**********************************************************************
684 * LoadBitmap32A (USER32.357)
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 if( bmp
->DDBitmap
) {
706 if( bmp
->DDBitmap
->funcs
->pDeleteObject
)
707 bmp
->DDBitmap
->funcs
->pDeleteObject( hbitmap
);
710 if( bmp
->bitmap
.bmBits
)
711 HeapFree( GetProcessHeap(), 0, bmp
->bitmap
.bmBits
);
713 DIB_DeleteDIBSection( bmp
);
715 return GDI_FreeObject( hbitmap
);
719 /***********************************************************************
722 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
726 if ( count
<= sizeof(BITMAP16
) )
728 BITMAP32
*bmp32
= &bmp
->dib
->dibSection
.dsBm
;
730 bmp16
.bmType
= bmp32
->bmType
;
731 bmp16
.bmWidth
= bmp32
->bmWidth
;
732 bmp16
.bmHeight
= bmp32
->bmHeight
;
733 bmp16
.bmWidthBytes
= bmp32
->bmWidthBytes
;
734 bmp16
.bmPlanes
= bmp32
->bmPlanes
;
735 bmp16
.bmBitsPixel
= bmp32
->bmBitsPixel
;
736 bmp16
.bmBits
= (SEGPTR
)0;
737 memcpy( buffer
, &bmp16
, count
);
742 FIXME(bitmap
, "not implemented for DIBs: count %d\n", count
);
749 bmp16
.bmType
= bmp
->bitmap
.bmType
;
750 bmp16
.bmWidth
= bmp
->bitmap
.bmWidth
;
751 bmp16
.bmHeight
= bmp
->bitmap
.bmHeight
;
752 bmp16
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
753 bmp16
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
754 bmp16
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
755 bmp16
.bmBits
= (SEGPTR
)0;
756 if (count
> sizeof(bmp16
)) count
= sizeof(bmp16
);
757 memcpy( buffer
, &bmp16
, count
);
763 /***********************************************************************
766 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
770 if (count
< sizeof(DIBSECTION
))
772 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
776 if (count
> sizeof(DIBSECTION
)) count
= sizeof(DIBSECTION
);
779 memcpy( buffer
, &bmp
->dib
->dibSection
, count
);
784 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
785 memcpy( buffer
, &bmp
->bitmap
, count
);
791 /***********************************************************************
792 * CreateDiscardableBitmap16 (GDI.156)
794 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
797 return CreateCompatibleBitmap16( hdc
, width
, height
);
801 /******************************************************************************
802 * CreateDiscardableBitmap32 [GDI32.38] Creates a discardable bitmap
805 * Success: Handle to bitmap
808 HBITMAP32 WINAPI
CreateDiscardableBitmap32(
809 HDC32 hdc
, /* [in] Handle to device context */
810 INT32 width
, /* [in] Bitmap width */
811 INT32 height
) /* [in] Bitmap height */
813 return CreateCompatibleBitmap32( hdc
, width
, height
);
817 /***********************************************************************
818 * GetBitmapDimensionEx16 (GDI.468)
821 * Can this call GetBitmapDimensionEx32?
823 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
825 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
826 if (!bmp
) return FALSE
;
827 CONV_SIZE32TO16( &bmp
->size
, size
);
828 GDI_HEAP_UNLOCK( hbitmap
);
833 /******************************************************************************
834 * GetBitmapDimensionEx32 [GDI32.144] Retrieves dimensions of a bitmap
840 BOOL32 WINAPI
GetBitmapDimensionEx32(
841 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
842 LPSIZE32 size
) /* [out] Address of struct receiving dimensions */
844 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
845 if (!bmp
) return FALSE
;
847 GDI_HEAP_UNLOCK( hbitmap
);
852 /***********************************************************************
853 * GetBitmapDimension (GDI.162)
855 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
858 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
859 return MAKELONG( size
.cx
, size
.cy
);
863 /***********************************************************************
864 * SetBitmapDimensionEx16 (GDI.478)
866 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
869 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
870 if (!bmp
) return FALSE
;
871 if (prevSize
) CONV_SIZE32TO16( &bmp
->size
, prevSize
);
874 GDI_HEAP_UNLOCK( hbitmap
);
879 /******************************************************************************
880 * SetBitmapDimensionEx32 [GDI32.304] Assignes dimensions to a bitmap
886 BOOL32 WINAPI
SetBitmapDimensionEx32(
887 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
888 INT32 x
, /* [in] Bitmap width */
889 INT32 y
, /* [in] Bitmap height */
890 LPSIZE32 prevSize
) /* [out] Address of structure for orig dims */
892 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
893 if (!bmp
) return FALSE
;
894 if (prevSize
) *prevSize
= bmp
->size
;
897 GDI_HEAP_UNLOCK( hbitmap
);
902 /***********************************************************************
903 * SetBitmapDimension (GDI.163)
905 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
908 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
909 return MAKELONG( size
.cx
, size
.cy
);