4 * Copyright 1993 Alexandre Julliard
15 #include "sysmetrics.h"
16 #include "cursoricon.h"
19 #include "wine/winuser16.h"
21 /***********************************************************************
24 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
26 INT32
BITMAP_GetPadding( int bmWidth
, int bpp
)
33 pad
= ((bmWidth
-1) & 8) ? 0 : 1;
37 pad
= (2 - (bmWidth
& 1)) & 1;
41 pad
= (bmWidth
*3) & 1;
47 pad
= 0; /* we have 16bit alignment already */
51 if (!(bmWidth
& 3)) pad
= 0;
52 else pad
= ((4 - (bmWidth
& 3)) + 1) / 2;
56 WARN(bitmap
,"Unknown depth %d, please report.\n", bpp
);
62 /***********************************************************************
63 * BITMAP_GetWidthBytes
65 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
68 INT32
BITMAP_GetWidthBytes( INT32 bmWidth
, INT32 bpp
)
73 return 2 * ((bmWidth
+15) >> 4);
76 bmWidth
*= 3; /* fall through */
78 return bmWidth
+ (bmWidth
& 1);
88 return 2 * ((bmWidth
+3) >> 2);
91 WARN(bitmap
,"Unknown depth %d, please report.\n", bpp
);
96 /***********************************************************************
97 * CreateUserBitmap16 (GDI.407)
99 HBITMAP16 WINAPI
CreateUserBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
100 UINT16 bpp
, LPCVOID bits
)
102 return CreateBitmap16( width
, height
, planes
, bpp
, bits
);
105 /***********************************************************************
106 * CreateUserDiscardableBitmap16 (GDI.409)
108 HBITMAP16 WINAPI
CreateUserDiscardableBitmap16( WORD dummy
,
109 INT16 width
, INT16 height
)
111 return CreateUserBitmap16( width
, height
, 1, MONITOR_GetDepth(&MONITOR_PrimaryMonitor
), NULL
);
115 /***********************************************************************
116 * CreateBitmap16 (GDI.48)
118 HBITMAP16 WINAPI
CreateBitmap16( INT16 width
, INT16 height
, UINT16 planes
,
119 UINT16 bpp
, LPCVOID bits
)
121 return CreateBitmap32( width
, height
, planes
, bpp
, bits
);
125 /******************************************************************************
126 * CreateBitmap32 [GDI32.25] Creates a bitmap with the specified info
129 * width [I] bitmap width
130 * height [I] bitmap height
131 * planes [I] Number of color planes
132 * bpp [I] Number of bits to identify a color
133 * bits [I] Pointer to array containing color data
136 * Success: Handle to bitmap
139 HBITMAP32 WINAPI
CreateBitmap32( INT32 width
, INT32 height
, UINT32 planes
,
140 UINT32 bpp
, LPCVOID bits
)
145 planes
= (BYTE
)planes
;
149 /* Check parameters */
150 if (!height
|| !width
) return 0;
152 FIXME(bitmap
, "planes = %d\n", planes
);
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;
162 TRACE(bitmap
, "%dx%d, %d colors returning %08x\n", width
, height
,
163 1 << (planes
*bpp
), hbitmap
);
165 bmp
= (BITMAPOBJ
*) GDI_HEAP_LOCK( hbitmap
);
169 bmp
->bitmap
.bmType
= 0;
170 bmp
->bitmap
.bmWidth
= width
;
171 bmp
->bitmap
.bmHeight
= height
;
172 bmp
->bitmap
.bmPlanes
= planes
;
173 bmp
->bitmap
.bmBitsPixel
= bpp
;
174 bmp
->bitmap
.bmWidthBytes
= BITMAP_GetWidthBytes( width
, bpp
);
175 bmp
->bitmap
.bmBits
= NULL
;
177 bmp
->DDBitmap
= NULL
;
180 if (bits
) /* Set bitmap bits */
181 SetBitmapBits32( hbitmap
, height
* bmp
->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] Creates a bitmap compatible with the DC
201 * hdc [I] Handle to device context
202 * width [I] Width of bitmap
203 * height [I] Height of bitmap
206 * Success: Handle to bitmap
209 HBITMAP32 WINAPI
CreateCompatibleBitmap32( HDC32 hdc
, INT32 width
, INT32 height
)
211 HBITMAP32 hbmpRet
= 0;
214 TRACE(bitmap
, "(%04x,%d,%d) = \n", hdc
, width
, height
);
215 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
216 if ((width
>= 0x10000) || (height
>= 0x10000)) {
217 FIXME(bitmap
,"got bad width %d or height %d, please look for reason\n",
220 hbmpRet
= CreateBitmap32( width
, height
, 1, dc
->w
.bitsPerPixel
, NULL
);
221 if(dc
->funcs
->pCreateBitmap
)
222 dc
->funcs
->pCreateBitmap( hbmpRet
);
224 TRACE(bitmap
,"\t\t%04x\n", hbmpRet
);
225 GDI_HEAP_UNLOCK(hdc
);
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
);
531 /******************************************************************************
532 * CopyImage16 [USER.390] Creates new image and copies attributes to it
535 HICON16 WINAPI
CopyImage16( HANDLE16 hnd
, UINT16 type
, INT16 desiredx
,
536 INT16 desiredy
, UINT16 flags
)
538 return (HICON16
)CopyImage32((HANDLE32
)hnd
, (UINT32
)type
, (INT32
)desiredx
,
539 (INT32
)desiredy
, (UINT32
)flags
);
542 /******************************************************************************
543 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
546 * hnd [I] Handle to image to copy
547 * type [I] Type of image to copy
548 * desiredx [I] Desired width of new image
549 * desiredy [I] Desired height of new image
550 * flags [I] Copy flags
553 * Success: Handle to newly created image
556 * FIXME: implementation still lacks nearly all features, see LR_*
557 * defines in windows.h
559 HICON32 WINAPI
CopyImage32( HANDLE32 hnd
, UINT32 type
, INT32 desiredx
,
560 INT32 desiredy
, UINT32 flags
)
565 return BITMAP_CopyBitmap(hnd
);
567 return CopyIcon32(hnd
);
569 return CopyCursor32(hnd
);
574 /**********************************************************************
575 * LoadBitmap16 (USER.175)
578 * Can this call LoadBitmap32?
580 HBITMAP16 WINAPI
LoadBitmap16( HINSTANCE16 instance
, SEGPTR name
)
582 HBITMAP32 hbitmap
= 0;
590 char *str
= (char *)PTR_SEG_TO_LIN( name
);
591 TRACE(bitmap
, "(%04x,'%s')\n", instance
, str
);
592 if (str
[0] == '#') name
= (SEGPTR
)(DWORD
)(WORD
)atoi( str
+ 1 );
595 TRACE(bitmap
, "(%04x,%04x)\n",
596 instance
, LOWORD(name
) );
598 if (!instance
) /* OEM bitmap */
603 if (HIWORD((int)name
)) return 0;
604 hdc
= CreateDC32A( "DISPLAY", NULL
, NULL
, NULL
);
605 dc
= DC_GetDCPtr( hdc
);
606 if(dc
->funcs
->pLoadOEMResource
)
607 hbitmap
= dc
->funcs
->pLoadOEMResource( LOWORD((int)name
),
609 GDI_HEAP_UNLOCK( hdc
);
614 if (!(hRsrc
= FindResource16( instance
, name
, RT_BITMAP16
))) return 0;
615 if (!(handle
= LoadResource16( instance
, hRsrc
))) return 0;
617 info
= (BITMAPINFO
*)LockResource16( handle
);
618 if ((hdc
= GetDC32(0)) != 0)
620 char *bits
= (char *)info
+ DIB_BitmapInfoSize( info
, DIB_RGB_COLORS
);
621 hbitmap
= CreateDIBitmap32( hdc
, &info
->bmiHeader
, CBM_INIT
,
622 bits
, info
, DIB_RGB_COLORS
);
623 ReleaseDC32( 0, hdc
);
625 FreeResource16( handle
);
630 /**********************************************************************
631 * BITMAP_LoadBitmap32W
633 HBITMAP32
BITMAP_LoadBitmap32W(HINSTANCE32 instance
,LPCWSTR name
,
636 HBITMAP32 hbitmap
= 0;
641 BITMAPINFO
*info
, *fix_info
=NULL
;
645 if (!(loadflags
& LR_LOADFROMFILE
)) {
646 if (!instance
) /* OEM bitmap */
651 if (HIWORD((int)name
)) return 0;
652 hdc
= CreateDC32A( "DISPLAY", NULL
, NULL
, NULL
);
653 dc
= DC_GetDCPtr( hdc
);
654 if(dc
->funcs
->pLoadOEMResource
)
655 hbitmap
= dc
->funcs
->pLoadOEMResource( LOWORD((int)name
),
657 GDI_HEAP_UNLOCK( hdc
);
662 if (!(hRsrc
= FindResource32W( instance
, name
, RT_BITMAP32W
))) return 0;
663 if (!(handle
= LoadResource32( instance
, hRsrc
))) return 0;
665 if ((info
= (BITMAPINFO
*)LockResource32( handle
)) == NULL
) return 0;
669 if (!(ptr
= (char *)VIRTUAL_MapFileW( name
))) return 0;
670 info
= (BITMAPINFO
*)(ptr
+ sizeof(BITMAPFILEHEADER
));
672 size
= DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
);
673 if ((hFix
= GlobalAlloc32(0, size
))) fix_info
=GlobalLock32(hFix
);
677 memcpy(fix_info
, info
, size
);
678 pix
= *((LPBYTE
)info
+DIB_BitmapInfoSize(info
, DIB_RGB_COLORS
));
679 DIB_FixColorsToLoadflags(fix_info
, loadflags
, pix
);
680 if ((hdc
= GetDC32(0)) != 0) {
681 if (loadflags
& LR_CREATEDIBSECTION
)
682 hbitmap
= CreateDIBSection32(hdc
, fix_info
, DIB_RGB_COLORS
, NULL
, 0, 0);
684 char *bits
= (char *)info
+ size
;;
685 hbitmap
= CreateDIBitmap32( hdc
, &fix_info
->bmiHeader
, CBM_INIT
,
686 bits
, fix_info
, DIB_RGB_COLORS
);
688 ReleaseDC32( 0, hdc
);
690 GlobalUnlock32(hFix
);
693 if (loadflags
& LR_LOADFROMFILE
) UnmapViewOfFile( ptr
);
698 /******************************************************************************
699 * LoadBitmap32W [USER32.358] Loads bitmap from the executable file
702 * Success: Handle to specified bitmap
705 HBITMAP32 WINAPI
LoadBitmap32W(
706 HINSTANCE32 instance
, /* [in] Handle to application instance */
707 LPCWSTR name
) /* [in] Address of bitmap resource name */
709 return BITMAP_LoadBitmap32W(instance
, name
, 0);
713 /**********************************************************************
714 * LoadBitmap32A (USER32.357)
716 HBITMAP32 WINAPI
LoadBitmap32A( HINSTANCE32 instance
, LPCSTR name
)
719 if (!HIWORD(name
)) res
= LoadBitmap32W( instance
, (LPWSTR
)name
);
722 LPWSTR uni
= HEAP_strdupAtoW( GetProcessHeap(), 0, name
);
723 res
= LoadBitmap32W( instance
, uni
);
724 HeapFree( GetProcessHeap(), 0, uni
);
730 /***********************************************************************
731 * BITMAP_DeleteObject
733 BOOL32
BITMAP_DeleteObject( HBITMAP16 hbitmap
, BITMAPOBJ
* bmp
)
735 if( bmp
->DDBitmap
) {
736 if( bmp
->DDBitmap
->funcs
->pDeleteObject
)
737 bmp
->DDBitmap
->funcs
->pDeleteObject( hbitmap
);
740 if( bmp
->bitmap
.bmBits
)
741 HeapFree( GetProcessHeap(), 0, bmp
->bitmap
.bmBits
);
743 DIB_DeleteDIBSection( bmp
);
745 return GDI_FreeObject( hbitmap
);
749 /***********************************************************************
752 INT16
BITMAP_GetObject16( BITMAPOBJ
* bmp
, INT16 count
, LPVOID buffer
)
756 if ( count
<= sizeof(BITMAP16
) )
758 BITMAP32
*bmp32
= &bmp
->dib
->dibSection
.dsBm
;
760 bmp16
.bmType
= bmp32
->bmType
;
761 bmp16
.bmWidth
= bmp32
->bmWidth
;
762 bmp16
.bmHeight
= bmp32
->bmHeight
;
763 bmp16
.bmWidthBytes
= bmp32
->bmWidthBytes
;
764 bmp16
.bmPlanes
= bmp32
->bmPlanes
;
765 bmp16
.bmBitsPixel
= bmp32
->bmBitsPixel
;
766 bmp16
.bmBits
= (SEGPTR
)0;
767 memcpy( buffer
, &bmp16
, count
);
772 FIXME(bitmap
, "not implemented for DIBs: count %d\n", count
);
779 bmp16
.bmType
= bmp
->bitmap
.bmType
;
780 bmp16
.bmWidth
= bmp
->bitmap
.bmWidth
;
781 bmp16
.bmHeight
= bmp
->bitmap
.bmHeight
;
782 bmp16
.bmWidthBytes
= bmp
->bitmap
.bmWidthBytes
;
783 bmp16
.bmPlanes
= bmp
->bitmap
.bmPlanes
;
784 bmp16
.bmBitsPixel
= bmp
->bitmap
.bmBitsPixel
;
785 bmp16
.bmBits
= (SEGPTR
)0;
786 if (count
> sizeof(bmp16
)) count
= sizeof(bmp16
);
787 memcpy( buffer
, &bmp16
, count
);
793 /***********************************************************************
796 INT32
BITMAP_GetObject32( BITMAPOBJ
* bmp
, INT32 count
, LPVOID buffer
)
800 if (count
< sizeof(DIBSECTION
))
802 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
806 if (count
> sizeof(DIBSECTION
)) count
= sizeof(DIBSECTION
);
809 memcpy( buffer
, &bmp
->dib
->dibSection
, count
);
814 if (count
> sizeof(BITMAP32
)) count
= sizeof(BITMAP32
);
815 memcpy( buffer
, &bmp
->bitmap
, count
);
821 /***********************************************************************
822 * CreateDiscardableBitmap16 (GDI.156)
824 HBITMAP16 WINAPI
CreateDiscardableBitmap16( HDC16 hdc
, INT16 width
,
827 return CreateCompatibleBitmap16( hdc
, width
, height
);
831 /******************************************************************************
832 * CreateDiscardableBitmap32 [GDI32.38] Creates a discardable bitmap
835 * Success: Handle to bitmap
838 HBITMAP32 WINAPI
CreateDiscardableBitmap32(
839 HDC32 hdc
, /* [in] Handle to device context */
840 INT32 width
, /* [in] Bitmap width */
841 INT32 height
) /* [in] Bitmap height */
843 return CreateCompatibleBitmap32( hdc
, width
, height
);
847 /***********************************************************************
848 * GetBitmapDimensionEx16 (GDI.468)
851 * Can this call GetBitmapDimensionEx32?
853 BOOL16 WINAPI
GetBitmapDimensionEx16( HBITMAP16 hbitmap
, LPSIZE16 size
)
855 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
856 if (!bmp
) return FALSE
;
857 CONV_SIZE32TO16( &bmp
->size
, size
);
858 GDI_HEAP_UNLOCK( hbitmap
);
863 /******************************************************************************
864 * GetBitmapDimensionEx32 [GDI32.144] Retrieves dimensions of a bitmap
870 BOOL32 WINAPI
GetBitmapDimensionEx32(
871 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
872 LPSIZE32 size
) /* [out] Address of struct receiving dimensions */
874 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
875 if (!bmp
) return FALSE
;
877 GDI_HEAP_UNLOCK( hbitmap
);
882 /***********************************************************************
883 * GetBitmapDimension (GDI.162)
885 DWORD WINAPI
GetBitmapDimension( HBITMAP16 hbitmap
)
888 if (!GetBitmapDimensionEx16( hbitmap
, &size
)) return 0;
889 return MAKELONG( size
.cx
, size
.cy
);
893 /***********************************************************************
894 * SetBitmapDimensionEx16 (GDI.478)
896 BOOL16 WINAPI
SetBitmapDimensionEx16( HBITMAP16 hbitmap
, INT16 x
, INT16 y
,
899 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
900 if (!bmp
) return FALSE
;
901 if (prevSize
) CONV_SIZE32TO16( &bmp
->size
, prevSize
);
904 GDI_HEAP_UNLOCK( hbitmap
);
909 /******************************************************************************
910 * SetBitmapDimensionEx32 [GDI32.304] Assignes dimensions to a bitmap
916 BOOL32 WINAPI
SetBitmapDimensionEx32(
917 HBITMAP32 hbitmap
, /* [in] Handle to bitmap */
918 INT32 x
, /* [in] Bitmap width */
919 INT32 y
, /* [in] Bitmap height */
920 LPSIZE32 prevSize
) /* [out] Address of structure for orig dims */
922 BITMAPOBJ
* bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
);
923 if (!bmp
) return FALSE
;
924 if (prevSize
) *prevSize
= bmp
->size
;
927 GDI_HEAP_UNLOCK( hbitmap
);
932 /***********************************************************************
933 * SetBitmapDimension (GDI.163)
935 DWORD WINAPI
SetBitmapDimension( HBITMAP16 hbitmap
, INT16 x
, INT16 y
)
938 if (!SetBitmapDimensionEx16( hbitmap
, x
, y
, &size
)) return 0;
939 return MAKELONG( size
.cx
, size
.cy
);