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",
219 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
220 if(dc
->funcs
->pCreateBitmap
)
221 dc
->funcs
->pCreateBitmap( hbmpRet
);
223 TRACE(bitmap
,"\t\t%04x\n", hbmpRet
);
224 GDI_HEAP_UNLOCK(hdc
);
229 /***********************************************************************
230 * CreateBitmapIndirect16 (GDI.49)
232 HBITMAP16 WINAPI
CreateBitmapIndirect16( const BITMAP16
* bmp
)
234 return CreateBitmap16( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
235 bmp
->bmBitsPixel
, PTR_SEG_TO_LIN( bmp
->bmBits
) );
239 /******************************************************************************
240 * CreateBitmapIndirect32 [GDI32.26] Creates a bitmap with the specifies info
243 * Success: Handle to bitmap
246 HBITMAP32 WINAPI
CreateBitmapIndirect32(
247 const BITMAP32
* bmp
) /* [in] Pointer to the bitmap data */
249 return CreateBitmap32( bmp
->bmWidth
, bmp
->bmHeight
, bmp
->bmPlanes
,
250 bmp
->bmBitsPixel
, bmp
->bmBits
);
254 /***********************************************************************
255 * GetBitmapBits16 (GDI.74)
257 LONG WINAPI
GetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPVOID buffer
)
259 return GetBitmapBits32( hbitmap
, count
, buffer
);
263 /***********************************************************************
264 * GetBitmapBits32 [GDI32.143] Copies bitmap bits of bitmap to buffer
267 * Success: Number of bytes copied
270 LONG WINAPI
GetBitmapBits32(
271 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
272 LONG count
, /* [in] Number of bytes to copy */
273 LPVOID bits
) /* [out] Pointer to buffer to receive bits */
275 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
281 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
285 /* Only get entire lines */
286 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
287 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
288 count
= height
* bmp
->bitmap
.bmWidthBytes
;
291 WARN(bitmap
, "Less then one entire line requested\n");
292 GDI_HEAP_UNLOCK( hbitmap
);
297 TRACE(bitmap
, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
298 hbitmap
, count
, bits
, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
299 1 << bmp
->bitmap
.bmBitsPixel
, height
);
303 TRACE(bitmap
, "Calling device specific BitmapBits\n");
304 if(bmp
->DDBitmap
->funcs
->pBitmapBits
)
305 ret
= bmp
->DDBitmap
->funcs
->pBitmapBits(hbitmap
, bits
, count
,
308 ERR(bitmap
, "BitmapBits == NULL??\n");
314 if(!bmp
->bitmap
.bmBits
) {
315 WARN(bitmap
, "Bitmap is empty\n");
318 memcpy(bits
, bmp
->bitmap
.bmBits
, count
);
324 GDI_HEAP_UNLOCK( hbitmap
);
329 /***********************************************************************
330 * SetBitmapBits16 (GDI.106)
332 LONG WINAPI
SetBitmapBits16( HBITMAP16 hbitmap
, LONG count
, LPCVOID buffer
)
334 return SetBitmapBits32( hbitmap
, count
, buffer
);
338 /******************************************************************************
339 * SetBitmapBits32 [GDI32.303] Sets bits of color data for a bitmap
342 * Success: Number of bytes used in setting the bitmap bits
345 LONG WINAPI
SetBitmapBits32(
346 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
347 LONG count
, /* [in] Number of bytes in bitmap array */
348 LPCVOID bits
) /* [in] Address of array with bitmap bits */
350 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
356 WARN(bitmap
, "(%ld): Negative number of bytes passed???\n", count
);
360 /* Only get entire lines */
361 height
= count
/ bmp
->bitmap
.bmWidthBytes
;
362 if (height
> bmp
->bitmap
.bmHeight
) height
= bmp
->bitmap
.bmHeight
;
363 count
= height
* bmp
->bitmap
.bmWidthBytes
;
365 TRACE(bitmap
, "(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
366 hbitmap
, count
, bits
, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
,
367 1 << bmp
->bitmap
.bmBitsPixel
, height
);
371 TRACE(bitmap
, "Calling device specific BitmapBits\n");
372 if(bmp
->DDBitmap
->funcs
->pBitmapBits
)
373 ret
= bmp
->DDBitmap
->funcs
->pBitmapBits(hbitmap
, (void *) bits
,
376 ERR(bitmap
, "BitmapBits == NULL??\n");
382 if(!bmp
->bitmap
.bmBits
) /* Alloc enough for entire bitmap */
383 bmp
->bitmap
.bmBits
= HeapAlloc( GetProcessHeap(), 0, count
);
384 if(!bmp
->bitmap
.bmBits
) {
385 WARN(bitmap
, "Unable to allocate bit buffer\n");
388 memcpy(bmp
->bitmap
.bmBits
, bits
, count
);
393 GDI_HEAP_UNLOCK( hbitmap
);
397 /***********************************************************************
398 * LoadImage16 [USER.389]
401 HANDLE16 WINAPI
LoadImage16( HINSTANCE16 hinst
, LPCSTR name
, UINT16 type
,
402 INT16 desiredx
, INT16 desiredy
, UINT16 loadflags
)
405 TRACE(resource
,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
406 hinst
,(char *)PTR_SEG_TO_LIN(name
),type
,desiredx
,desiredy
,loadflags
);
408 TRACE(resource
,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
409 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
413 return LoadBitmap16(hinst
,(SEGPTR
)name
);
415 return LoadIcon16(hinst
,(SEGPTR
)name
);
417 return LoadCursor16(hinst
,(SEGPTR
)name
);
423 /**********************************************************************
424 * LoadImage32A (USER32.365)
426 * FIXME: implementation lacks some features, see LR_ defines in windows.h
429 HANDLE32 WINAPI
LoadImage32A( HINSTANCE32 hinst
, LPCSTR name
, UINT32 type
,
430 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
435 if (HIWORD(name
)) u_name
= HEAP_strdupAtoW(GetProcessHeap(), 0, name
);
436 else u_name
=(LPWSTR
)name
;
437 res
= LoadImage32W(hinst
, u_name
, type
, desiredx
, desiredy
, loadflags
);
438 if (HIWORD(name
)) HeapFree(GetProcessHeap(), 0, u_name
);
443 /******************************************************************************
444 * LoadImage32W [USER32.366] Loads an icon, cursor, or bitmap
447 * hinst [I] Handle of instance that contains image
448 * name [I] Name of image
449 * type [I] Type of image
450 * desiredx [I] Desired width
451 * desiredy [I] Desired height
452 * loadflags [I] Load flags
455 * Success: Handle to newly loaded image
458 * FIXME: Implementation lacks some features, see LR_ defines in windows.h
460 HANDLE32 WINAPI
LoadImage32W( HINSTANCE32 hinst
, LPCWSTR name
, UINT32 type
,
461 INT32 desiredx
, INT32 desiredy
, UINT32 loadflags
)
464 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
465 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
467 TRACE(resource
,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
468 hinst
,name
,type
,desiredx
,desiredy
,loadflags
);
470 if (loadflags
& LR_DEFAULTSIZE
) {
471 if (type
== IMAGE_ICON
) {
472 if (!desiredx
) desiredx
= SYSMETRICS_CXICON
;
473 if (!desiredy
) desiredy
= SYSMETRICS_CYICON
;
474 } else if (type
== IMAGE_CURSOR
) {
475 if (!desiredx
) desiredx
= SYSMETRICS_CXCURSOR
;
476 if (!desiredy
) desiredy
= SYSMETRICS_CYCURSOR
;
479 if (loadflags
& LR_LOADFROMFILE
) loadflags
&= ~LR_SHARED
;
482 return BITMAP_LoadBitmap32W(hinst
, name
, loadflags
);
486 HDC32 hdc
= GetDC32(0);
487 UINT32 palEnts
= GetSystemPaletteEntries32(hdc
, 0, 0, NULL
);
490 return CURSORICON_Load32(hinst
, name
, desiredx
, desiredy
,
491 MIN(16, palEnts
), FALSE
, loadflags
);
495 return CURSORICON_Load32(hinst
, name
, desiredx
, desiredy
,
502 /**********************************************************************
506 HBITMAP32
BITMAP_CopyBitmap(HBITMAP32 hbitmap
)
508 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
516 res
= CreateBitmapIndirect32(&bm
);
519 char *buf
= HeapAlloc( GetProcessHeap(), 0, bm
.bmWidthBytes
*
521 GetBitmapBits32 (hbitmap
, bm
.bmWidthBytes
* bm
.bmHeight
, buf
);
522 SetBitmapBits32 (res
, bm
.bmWidthBytes
* bm
.bmHeight
, buf
);
523 HeapFree( GetProcessHeap(), 0, buf
);
526 GDI_HEAP_UNLOCK( hbitmap
);
531 /******************************************************************************
532 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
535 * hnd [I] Handle to image to copy
536 * type [I] Type of image to copy
537 * desiredx [I] Desired width of new image
538 * desiredy [I] Desired height of new image
539 * flags [I] Copy flags
542 * Success: Handle to newly created image
545 * FIXME: implementation still lacks nearly all features, see LR_*
546 * defines in windows.h
548 HICON32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
549 INT32 desiredy
, UINT32 flags
)
554 return BITMAP_CopyBitmap(hnd
);
556 return CopyIcon32(hnd
);
558 return CopyCursor32(hnd
);
563 /**********************************************************************
564 * LoadBitmap16 (USER.175)
567 * Can this call LoadBitmap32?
569 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
571 HBITMAP32 hbitmap
= 0;
579 char *str
= (char *)PTR_SEG_TO_LIN( name
);
580 TRACE(bitmap
, "(%04x,'%s')\n", instance
, str
);
581 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
584 TRACE(bitmap
, "(%04x,%04x)\n",
585 instance
, LOWORD(name
) );
587 if (!instance
) /* OEM bitmap */
592 if (HIWORD((int)name
)) return 0;
593 hdc
= CreateDC32A( "DISPLAY", NULL
, NULL
, NULL
);
594 dc
= DC_GetDCPtr( hdc
);
595 if(dc
->funcs
->pLoadOEMResource
)
596 hbitmap
= dc
->funcs
->pLoadOEMResource( LOWORD((int)name
),
598 GDI_HEAP_UNLOCK( hdc
);
603 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP16
))) return 0;
604 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
606 info
= (BITMAPINFO
*)LockResource16( handle
);
607 if ((hdc
= GetDC32(0)) != 0)
609 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
610 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
611 bits
, info
, DIB_RGB_COLORS
);
612 ReleaseDC32( 0, hdc
);
614 FreeResource16( handle
);
619 /**********************************************************************
620 * BITMAP_LoadBitmap32W
622 HBITMAP32
BITMAP_LoadBitmap32W(HINSTANCE32 instance
,LPCWSTR name
,
625 HBITMAP32 hbitmap
= 0;
630 BITMAPINFO
*info
, *fix_info
=NULL
;
634 if (!(loadflags
& LR_LOADFROMFILE
)) {
635 if (!instance
) /* OEM bitmap */
640 if (HIWORD((int)name
)) return 0;
641 hdc
= CreateDC32A( "DISPLAY", NULL
, NULL
, NULL
);
642 dc
= DC_GetDCPtr( hdc
);
643 if(dc
->funcs
->pLoadOEMResource
)
644 hbitmap
= dc
->funcs
->pLoadOEMResource( LOWORD((int)name
),
646 GDI_HEAP_UNLOCK( hdc
);
651 if (!(hRsrc
= FindResource32W( instance
, name
, RT_BITMAP32W
))) return 0;
652 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
654 if ((info
= (BITMAPINFO
*)LockResource32( handle
)) == NULL
) return 0;
658 if (!(ptr
= (char *)VIRTUAL_MapFileW( name
))) return 0;
659 info
= (BITMAPINFO
*)(ptr
+ sizeof(BITMAPFILEHEADER
));
661 size
= DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
);
662 if ((hFix
= GlobalAlloc32(0, size
))) fix_info
=GlobalLock32(hFix
);
666 memcpy(fix_info
, info
, size
);
667 pix
= *((LPBYTE
)info
+DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
));
668 DIB_FixColorsToLoadflags(fix_info
, loadflags
, pix
);
669 if ((hdc
= GetDC32(0)) != 0) {
670 if (loadflags
& LR_CREATEDIBSECTION
)
671 hbitmap
= CreateDIBSection32(hdc
, fix_info
, DIB_RGB_COLORS
, NULL
, 0, 0);
673 char *bits
= (char *)info
+ size
;;
674 hbitmap
= CreateDIBitmap32( hdc
, &fix_info
->bmiHeader
, CBM_INIT
,
675 bits
, fix_info
, DIB_RGB_COLORS
);
677 ReleaseDC32( 0, hdc
);
679 GlobalUnlock32(hFix
);
682 if (loadflags
& LR_LOADFROMFILE
) UnmapViewOfFile( ptr
);
687 /******************************************************************************
688 * LoadBitmap32W [USER32.358] Loads bitmap from the executable file
691 * Success: Handle to specified bitmap
694 HBITMAP32 WINAPI
LoadBitmap32W(
695 HINSTANCE32 instance
, /* [in] Handle to application instance */
696 LPCWSTR name
) /* [in] Address of bitmap resource name */
698 return BITMAP_LoadBitmap32W(instance
, name
, 0);
702 /**********************************************************************
703 * LoadBitmap32A (USER32.357)
705 HBITMAP32 WINAPI
LoadBitmap32A( HINSTANCE32 instance
, LPCSTR name
)
708 if (!HIWORD(name
)) res
= LoadBitmap32W( instance
, (LPWSTR
)name
);
711 LPWSTR uni
= HEAP_strdupAtoW( GetProcessHeap(), 0, name
);
712 res
= LoadBitmap32W( instance
, uni
);
713 HeapFree( GetProcessHeap(), 0, uni
);
719 /***********************************************************************
720 * BITMAP_DeleteObject
722 BOOL32
BITMAP_DeleteObject( HBITMAP16 hbitmap
, BITMAPOBJ
* bmp
)
724 if( bmp
->DDBitmap
) {
725 if( bmp
->DDBitmap
->funcs
->pDeleteObject
)
726 bmp
->DDBitmap
->funcs
->pDeleteObject( hbitmap
);
729 if( bmp
->bitmap
.bmBits
)
730 HeapFree( GetProcessHeap(), 0, bmp
->bitmap
.bmBits
);
732 DIB_DeleteDIBSection( bmp
);
734 return GDI_FreeObject( hbitmap
);
738 /***********************************************************************
741 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
745 if ( count
<= sizeof(BITMAP16
) )
747 BITMAP32
*bmp32
= &bmp
->dib
->dibSection
.dsBm
;
749 bmp16
.bmType
= bmp32
->bmType
;
750 bmp16
.bmWidth
= bmp32
->bmWidth
;
751 bmp16
.bmHeight
= bmp32
->bmHeight
;
752 bmp16
.bmWidthBytes
= bmp32
->bmWidthBytes
;
753 bmp16
.bmPlanes
= bmp32
->bmPlanes
;
754 bmp16
.bmBitsPixel
= bmp32
->bmBitsPixel
;
755 bmp16
.bmBits
= (SEGPTR
)0;
756 memcpy( buffer
, &bmp16
, count
);
761 FIXME(bitmap
, "not implemented for DIBs: count %d\n", count
);
768 bmp16
.bmType
= bmp
->bitmap
.bmType
;
769 bmp16
.bmWidth
= bmp
->bitmap
.bmWidth
;
770 bmp16
.bmHeight
= bmp
->bitmap
.bmHeight
;
771 bmp16
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
772 bmp16
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
773 bmp16
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
774 bmp16
.bmBits
= (SEGPTR
)0;
775 if (count
> sizeof(bmp16
)) count
= sizeof(bmp16
);
776 memcpy( buffer
, &bmp16
, count
);
782 /***********************************************************************
785 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
789 if (count
< sizeof(DIBSECTION
))
791 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
795 if (count
> sizeof(DIBSECTION
)) count
= sizeof(DIBSECTION
);
798 memcpy( buffer
, &bmp
->dib
->dibSection
, count
);
803 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
804 memcpy( buffer
, &bmp
->bitmap
, count
);
810 /***********************************************************************
811 * CreateDiscardableBitmap16 (GDI.156)
813 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
816 return CreateCompatibleBitmap16( hdc
, width
, height
);
820 /******************************************************************************
821 * CreateDiscardableBitmap32 [GDI32.38] Creates a discardable bitmap
824 * Success: Handle to bitmap
827 HBITMAP32 WINAPI
CreateDiscardableBitmap32(
828 HDC32 hdc
, /* [in] Handle to device context */
829 INT32 width
, /* [in] Bitmap width */
830 INT32 height
) /* [in] Bitmap height */
832 return CreateCompatibleBitmap32( hdc
, width
, height
);
836 /***********************************************************************
837 * GetBitmapDimensionEx16 (GDI.468)
840 * Can this call GetBitmapDimensionEx32?
842 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
844 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
845 if (!bmp
) return FALSE
;
846 CONV_SIZE32TO16( &bmp
->size
, size
);
847 GDI_HEAP_UNLOCK( hbitmap
);
852 /******************************************************************************
853 * GetBitmapDimensionEx32 [GDI32.144] Retrieves dimensions of a bitmap
859 BOOL32 WINAPI
GetBitmapDimensionEx32(
860 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
861 LPSIZE32 size
) /* [out] Address of struct receiving dimensions */
863 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
864 if (!bmp
) return FALSE
;
866 GDI_HEAP_UNLOCK( hbitmap
);
871 /***********************************************************************
872 * GetBitmapDimension (GDI.162)
874 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
877 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
878 return MAKELONG( size
.cx
, size
.cy
);
882 /***********************************************************************
883 * SetBitmapDimensionEx16 (GDI.478)
885 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
888 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
889 if (!bmp
) return FALSE
;
890 if (prevSize
) CONV_SIZE32TO16( &bmp
->size
, prevSize
);
893 GDI_HEAP_UNLOCK( hbitmap
);
898 /******************************************************************************
899 * SetBitmapDimensionEx32 [GDI32.304] Assignes dimensions to a bitmap
905 BOOL32 WINAPI
SetBitmapDimensionEx32(
906 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
907 INT32 x
, /* [in] Bitmap width */
908 INT32 y
, /* [in] Bitmap height */
909 LPSIZE32 prevSize
) /* [out] Address of structure for orig dims */
911 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
912 if (!bmp
) return FALSE
;
913 if (prevSize
) *prevSize
= bmp
->size
;
916 GDI_HEAP_UNLOCK( hbitmap
);
921 /***********************************************************************
922 * SetBitmapDimension (GDI.163)
924 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
927 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
928 return MAKELONG( size
.cx
, size
.cy
);