4 * Copyright 1993 Alexandre Julliard
18 #ifdef PRELIMINARY_WING16_SUPPORT
19 #include <sys/types.h>
24 /* GCs used for B&W and color bitmap operations */
25 GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
27 /***********************************************************************
30 * Wrapper to call XPutImage with CALL_LARGE_STACK.
33 struct XPutImage_descr
41 static int XPutImage_wrapper( const struct XPutImage_descr *descr )
43 return XPutImage( display, descr->bmp->pixmap, BITMAP_GC(descr->bmp),
44 descr->image, 0, 0, 0, 0, descr->width, descr->height );
47 /***********************************************************************
48 * BITMAP_GetBitsPadding
50 * Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
52 INT32 BITMAP_GetBitsPadding( int bmWidth, int bpp )
59 if (!(bmWidth & 15)) pad = 0;
60 else pad = ((16 - (bmWidth & 15)) + 7) / 8;
64 pad = (2 - (bmWidth & 1)) & 1;
68 pad = (bmWidth*3) & 1;
74 pad = 0; /* we have 16bit alignment already */
78 if (!(bmWidth & 3)) pad = 0;
79 else pad = ((4 - (bmWidth & 3)) + 1) / 2;
83 WARN(bitmap,"Unknown depth %d, please report.\n", bpp );
89 /***********************************************************************
92 * Return number of bytes taken by a scanline of 16-bit aligned Windows DDB data.
94 INT32 BITMAP_GetBitsWidth( int bmWidth, int bpp )
99 return 2 * ((bmWidth+15) >> 4);
102 bmWidth *= 3; /* fall through */
104 return bmWidth + (bmWidth & 1);
114 return 2 * ((bmWidth+3) >> 2);
117 WARN(bitmap,"Unknown depth %d, please report.\n", bpp );
122 /***********************************************************************
123 * CreateBitmap16 (GDI.48)
125 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
126 UINT16 bpp, LPCVOID bits )
128 return CreateBitmap32( width, height, planes, bpp, bits );
132 /******************************************************************************
133 * CreateBitmap32 [GDI32.25] Creates a bitmap with the specified info
136 * width [I] bitmap width
137 * height [I] bitmap height
138 * planes [I] Number of color planes
139 * bpp [I] Number of bits to identify a color
140 * bits [I] Pointer to array containing color data
143 * Success: Handle to bitmap
146 HBITMAP32 WINAPI CreateBitmap32( INT32 width, INT32 height, UINT32 planes,
147 UINT32 bpp, LPCVOID bits )
149 BITMAPOBJ * bmpObjPtr;
152 planes = (BYTE)planes;
155 TRACE(gdi, "%dx%d, %d colors\n", width, height, 1 << (planes*bpp) );
157 /* Check parameters */
158 if (!height || !width || planes != 1) return 0;
159 if ((bpp != 1) && (bpp != screenDepth)) return 0;
160 if (height < 0) height = -height;
161 if (width < 0) width = -width;
163 /* Create the BITMAPOBJ */
164 hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
165 if (!hbitmap) return 0;
166 bmpObjPtr = (BITMAPOBJ *) GDI_HEAP_LOCK( hbitmap );
168 bmpObjPtr->size.cx = 0;
169 bmpObjPtr->size.cy = 0;
170 bmpObjPtr->bitmap.bmType = 0;
171 bmpObjPtr->bitmap.bmWidth = (INT16)width;
172 bmpObjPtr->bitmap.bmHeight = (INT16)height;
173 bmpObjPtr->bitmap.bmPlanes = (BYTE)planes;
174 bmpObjPtr->bitmap.bmBitsPixel = (BYTE)bpp;
175 bmpObjPtr->bitmap.bmWidthBytes = (INT16)BITMAP_WIDTH_BYTES( width, bpp );
176 bmpObjPtr->bitmap.bmBits = NULL;
178 bmpObjPtr->dibSection = NULL;
179 bmpObjPtr->colorMap = NULL;
180 bmpObjPtr->nColorMap = 0;
182 /* Create the pixmap */
183 bmpObjPtr->pixmap = TSXCreatePixmap(display, rootWindow, width, height, bpp);
184 if (!bmpObjPtr->pixmap)
186 GDI_HEAP_FREE( hbitmap );
189 else if (bits) /* Set bitmap bits */
190 SetBitmapBits32( hbitmap, height * bmpObjPtr->bitmap.bmWidthBytes,
192 GDI_HEAP_UNLOCK( hbitmap );
197 /***********************************************************************
198 * CreateCompatibleBitmap16 (GDI.51)
200 HBITMAP16 WINAPI CreateCompatibleBitmap16(HDC16 hdc, INT16 width, INT16 height)
202 return CreateCompatibleBitmap32( hdc, width, height );
206 /******************************************************************************
207 * CreateCompatibleBitmap32 [GDI32.30] Creates a bitmap compatible with the DC
210 * hdc [I] Handle to device context
211 * width [I] Width of bitmap
212 * height [I] Height of bitmap
215 * Success: Handle to bitmap
218 HBITMAP32 WINAPI CreateCompatibleBitmap32( HDC32 hdc, INT32 width, INT32 height)
220 HBITMAP32 hbmpRet = 0;
223 TRACE(gdi, "(%04x,%d,%d) = \n", hdc, width, height );
224 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
225 if ((width >0x1000) || (height > 0x1000))
227 FIXME(gdi,"got bad width %d or height %d, please look for reason\n",
231 hbmpRet = CreateBitmap32( width, height, 1, dc->w.bitsPerPixel, NULL );
232 TRACE(gdi,"\t\t%04x\n", hbmpRet);
237 /***********************************************************************
238 * CreateBitmapIndirect16 (GDI.49)
240 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
242 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
243 bmp->bmBitsPixel, PTR_SEG_TO_LIN( bmp->bmBits ) );
247 /******************************************************************************
248 * CreateBitmapIndirect32 [GDI32.26] Creates a bitmap with the specifies info
251 * Success: Handle to bitmap
254 HBITMAP32 WINAPI CreateBitmapIndirect32(
255 const BITMAP32 * bmp) /* [in] Pointer to the bitmap data */
257 return CreateBitmap32( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
258 bmp->bmBitsPixel, bmp->bmBits );
262 /***********************************************************************
265 * Get an X image for a bitmap. For use with CALL_LARGE_STACK.
267 XImage *BITMAP_GetXImage( const BITMAPOBJ *bmp )
269 return XGetImage( display, bmp->pixmap, 0, 0, bmp->bitmap.bmWidth,
270 bmp->bitmap.bmHeight, AllPlanes, ZPixmap );
274 /***********************************************************************
275 * GetBitmapBits16 (GDI.74)
277 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
279 return GetBitmapBits32( hbitmap, count, buffer );
283 /***********************************************************************
284 * GetBitmapBits32 [GDI32.143] Copies bitmap bits of bitmap to buffer
287 * Success: Number of bytes copied
290 LONG WINAPI GetBitmapBits32(
291 HBITMAP32 hbitmap, /* [in] Handle to bitmap */
292 LONG count, /* [in] Number of bytes to copy */
293 LPVOID buffer) /* [out] Pointer to buffer to receive bits */
296 LONG height, old_height;
303 WARN(bitmap, "(%ld): Negative number of bytes passed???\n", count );
306 bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
309 /* Only get entire lines */
310 height = count / bmp->bitmap.bmWidthBytes;
311 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
313 TRACE(bitmap, "%dx%d %d colors %p fetched height: %ld\n",
314 bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
315 1 << bmp->bitmap.bmBitsPixel, buffer, height );
317 pad = BITMAP_GetBitsPadding( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel );
319 if (!height || (pad == -1))
321 GDI_HEAP_UNLOCK( hbitmap );
325 EnterCriticalSection( &X11DRV_CritSection );
327 /* Hack: change the bitmap height temporarily to avoid */
328 /* getting unnecessary bitmap rows. */
329 old_height = bmp->bitmap.bmHeight;
330 bmp->bitmap.bmHeight = height;
331 image = (XImage *)CALL_LARGE_STACK( BITMAP_GetXImage, bmp );
332 bmp->bitmap.bmHeight = old_height;
334 /* copy XImage to 16 bit padded image buffer with real bitsperpixel */
337 switch (bmp->bitmap.bmBitsPixel)
340 for (h=0;h<height;h++)
343 for (w=0;w<bmp->bitmap.bmWidth;w++)
347 *tbuf |= XGetPixel(image,w,h)<<(7-(w&7));
348 if ((w&7) == 7) ++tbuf;
354 for (h=0;h<height;h++)
356 for (w=0;w<bmp->bitmap.bmWidth;w++)
358 if (!(w & 1)) *tbuf = XGetPixel( image, w, h) << 4;
359 else *tbuf++ |= XGetPixel( image, w, h) & 0x0f;
365 for (h=0;h<height;h++)
367 for (w=0;w<bmp->bitmap.bmWidth;w++)
368 *tbuf++ = XGetPixel(image,w,h);
374 for (h=0;h<height;h++)
376 for (w=0;w<bmp->bitmap.bmWidth;w++)
378 long pixel = XGetPixel(image,w,h);
380 *tbuf++ = pixel & 0xff;
381 *tbuf++ = (pixel>>8) & 0xff;
386 for (h=0;h<height;h++)
388 for (w=0;w<bmp->bitmap.bmWidth;w++)
390 long pixel = XGetPixel(image,w,h);
392 *tbuf++ = pixel & 0xff;
393 *tbuf++ = (pixel>> 8) & 0xff;
394 *tbuf++ = (pixel>>16) & 0xff;
400 FIXME(bitmap, "Unhandled bits:%d\n", bmp->bitmap.bmBitsPixel);
402 XDestroyImage( image );
403 LeaveCriticalSection( &X11DRV_CritSection );
405 GDI_HEAP_UNLOCK( hbitmap );
406 return height * bmp->bitmap.bmWidthBytes;
410 /***********************************************************************
411 * SetBitmapBits16 (GDI.106)
413 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
415 return SetBitmapBits32( hbitmap, count, buffer );
419 /******************************************************************************
420 * SetBitmapBits32 [GDI32.303] Sets bits of color data for a bitmap
423 * Success: Number of bytes used in setting the bitmap bits
426 LONG WINAPI SetBitmapBits32(
427 HBITMAP32 hbitmap, /* [in] Handle to bitmap */
428 LONG count, /* [in] Number of bytes in bitmap array */
429 LPCVOID buffer) /* [in] Address of array with bitmap bits */
431 struct XPutImage_descr descr;
435 LPBYTE sbuf,tmpbuffer;
436 int w,h,pad,widthbytes;
440 WARN(bitmap, "(%ld): Negative number of bytes passed???\n", count );
443 bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
446 TRACE(bitmap, "%dx%d %d colors %p\n",
447 bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
448 1 << bmp->bitmap.bmBitsPixel, buffer );
450 /* Only set entire lines */
451 height = count / bmp->bitmap.bmWidthBytes;
452 if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
454 pad = BITMAP_GetBitsPadding( bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel );
456 if (!height || (pad == -1))
458 GDI_HEAP_UNLOCK( hbitmap );
462 sbuf = (LPBYTE)buffer;
464 widthbytes = DIB_GetXImageWidthBytes(bmp->bitmap.bmWidth,bmp->bitmap.bmBitsPixel);
465 tmpbuffer = (LPBYTE)xmalloc(widthbytes*height);
467 EnterCriticalSection( &X11DRV_CritSection );
468 image = XCreateImage( display, DefaultVisualOfScreen(screen),
469 bmp->bitmap.bmBitsPixel, ZPixmap, 0, tmpbuffer,
470 bmp->bitmap.bmWidth,height,32,widthbytes );
472 /* copy 16 bit padded image buffer with real bitsperpixel to XImage */
473 sbuf = (LPBYTE)buffer;
474 switch (bmp->bitmap.bmBitsPixel)
477 for (h=0;h<height;h++)
479 for (w=0;w<bmp->bitmap.bmWidth;w++)
481 XPutPixel(image,w,h,(sbuf[0]>>(7-(w&7))) & 1);
489 for (h=0;h<height;h++)
491 for (w=0;w<bmp->bitmap.bmWidth;w++)
493 if (!(w & 1)) XPutPixel( image, w, h, *sbuf >> 4 );
494 else XPutPixel( image, w, h, *sbuf++ & 0xf );
500 for (h=0;h<height;h++)
502 for (w=0;w<bmp->bitmap.bmWidth;w++)
503 XPutPixel(image,w,h,*sbuf++);
509 for (h=0;h<height;h++)
511 for (w=0;w<bmp->bitmap.bmWidth;w++)
513 XPutPixel(image,w,h,sbuf[1]*256+sbuf[0]);
519 for (h=0;h<height;h++)
521 for (w=0;w<bmp->bitmap.bmWidth;w++)
523 XPutPixel(image,w,h,(sbuf[2]<<16)+(sbuf[1]<<8)+sbuf[0]);
533 descr.width = bmp->bitmap.bmWidth;
534 descr.height = height;
535 CALL_LARGE_STACK( XPutImage_wrapper, &descr );
536 XDestroyImage( image ); /* frees tmpbuffer too */
537 LeaveCriticalSection( &X11DRV_CritSection );
539 GDI_HEAP_UNLOCK( hbitmap );
540 return height * bmp->bitmap.bmWidthBytes;
543 /***********************************************************************
544 * LoadImage16 [USER.389]
547 HANDLE16 WINAPI LoadImage16( HINSTANCE16 hinst, LPCSTR name, UINT16 type,
548 INT16 desiredx, INT16 desiredy, UINT16 loadflags)
551 TRACE(resource,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
552 hinst,(char *)PTR_SEG_TO_LIN(name),type,desiredx,desiredy,loadflags);
554 TRACE(resource,"LoadImage16(0x%04x,%p,%d,%d,%d,0x%08x)\n",
555 hinst,name,type,desiredx,desiredy,loadflags);
559 return LoadBitmap16(hinst,(SEGPTR)name);
561 return LoadIcon16(hinst,(SEGPTR)name);
563 return LoadCursor16(hinst,(SEGPTR)name);
569 /**********************************************************************
570 * LoadImage32A (USER32.365)
572 * FIXME: implementation still lacks nearly all features, see LR_*
573 * defines in windows.h
576 HANDLE32 WINAPI LoadImage32A( HINSTANCE32 hinst, LPCSTR name, UINT32 type,
577 INT32 desiredx, INT32 desiredy, UINT32 loadflags)
580 TRACE(resource,"(0x%04x,%s,%d,%d,%d,0x%08x)\n",
581 hinst,name,type,desiredx,desiredy,loadflags
584 TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
585 hinst,name,type,desiredx,desiredy,loadflags
590 return LoadBitmap32A(hinst,name);
592 return LoadIcon32A(hinst,name);
594 return LoadCursor32A(hinst,name);
599 /**********************************************************************
600 * LoadImage32W (USER32.366)
602 * FIXME: implementation still lacks nearly all features, see LR_*
603 * defines in windows.h
607 /******************************************************************************
608 * LoadImage32W [USER32.366] Loads an icon, cursor, or bitmap
611 * hinst [I] Handle of instance that contains image
612 * name [I] Name of image
613 * type [I] Type of image
614 * desiredx [I] Desired width
615 * desiredy [I] Desired height
616 * loadflags [I] Load flags
619 * Success: Handle to newly loaded image
623 * Implementation still lacks nearly all features, see LR_*
624 * defines in windows.h
626 HANDLE32 WINAPI LoadImage32W( HINSTANCE32 hinst, LPCWSTR name, UINT32 type,
627 INT32 desiredx, INT32 desiredy, UINT32 loadflags )
630 TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
631 hinst,name,type,desiredx,desiredy,loadflags
634 TRACE(resource,"(0x%04x,%p,%d,%d,%d,0x%08x)\n",
635 hinst,name,type,desiredx,desiredy,loadflags
641 return LoadBitmap32W(hinst,name);
643 return LoadIcon32W(hinst,name);
645 return LoadCursor32W(hinst,name);
651 /**********************************************************************
652 * CopyBitmap32 (not an API)
655 * If it is not an API, why is it declared with WINAPI?
658 HBITMAP32 WINAPI CopyBitmap32 (HBITMAP32 hnd)
663 if (GetObject32A (hnd, sizeof (bmp), &bmp))
665 res = CreateBitmapIndirect32 (&bmp);
666 SetBitmapBits32 (res, bmp.bmWidthBytes * bmp.bmHeight, bmp.bmBits);
672 /******************************************************************************
673 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
676 * hnd [I] Handle to image to copy
677 * type [I] Type of image to copy
678 * desiredx [I] Desired width of new image
679 * desiredy [I] Desired height of new image
680 * flags [I] Copy flags
683 * Success: Handle to newly created image
686 * FIXME: implementation still lacks nearly all features, see LR_*
687 * defines in windows.h
689 HANDLE32 WINAPI CopyImage32( HANDLE32 hnd, UINT32 type, INT32 desiredx,
690 INT32 desiredy, UINT32 flags )
695 return CopyBitmap32(hnd);
697 return CopyIcon32(hnd);
699 return CopyCursor32(hnd);
705 /**********************************************************************
706 * LoadBitmap16 (USER.175)
709 * Can this call LoadBitmap32?
711 HBITMAP16 WINAPI LoadBitmap16( HINSTANCE16 instance, SEGPTR name )
713 HBITMAP32 hbitmap = 0;
721 char *str = (char *)PTR_SEG_TO_LIN( name );
722 TRACE(bitmap, "(%04x,'%s')\n", instance, str );
723 if (str[0] == '#') name = (SEGPTR)(DWORD)(WORD)atoi( str + 1 );
726 TRACE(bitmap, "(%04x,%04x)\n",
727 instance, LOWORD(name) );
729 if (!instance) /* OEM bitmap */
731 if (HIWORD((int)name)) return 0;
732 return OBM_LoadBitmap( LOWORD((int)name) );
735 if (!(hRsrc = FindResource16( instance, name, RT_BITMAP16 ))) return 0;
736 if (!(handle = LoadResource16( instance, hRsrc ))) return 0;
738 info = (BITMAPINFO *)LockResource16( handle );
739 if ((hdc = GetDC32(0)) != 0)
741 char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
742 hbitmap = CreateDIBitmap32( hdc, &info->bmiHeader, CBM_INIT,
743 bits, info, DIB_RGB_COLORS );
744 ReleaseDC32( 0, hdc );
746 FreeResource16( handle );
751 /******************************************************************************
752 * LoadBitmap32W [USER32.358] Loads bitmap from the executable file
755 * Success: Handle to specified bitmap
758 HBITMAP32 WINAPI LoadBitmap32W(
759 HINSTANCE32 instance, /* [in] Handle to application instance */
760 LPCWSTR name) /* [in] Address of bitmap resource name */
762 HBITMAP32 hbitmap = 0;
768 if (!instance) /* OEM bitmap */
770 if (HIWORD((int)name)) return 0;
771 return OBM_LoadBitmap( LOWORD((int)name) );
774 if (!(hRsrc = FindResource32W( instance, name, RT_BITMAP32W ))) return 0;
775 if (!(handle = LoadResource32( instance, hRsrc ))) return 0;
777 info = (BITMAPINFO *)LockResource32( handle );
778 if ((hdc = GetDC32(0)) != 0)
780 char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
781 hbitmap = CreateDIBitmap32( hdc, &info->bmiHeader, CBM_INIT,
782 bits, info, DIB_RGB_COLORS );
783 ReleaseDC32( 0, hdc );
789 /**********************************************************************
790 * LoadBitmap32A (USER32.357)
792 HBITMAP32 WINAPI LoadBitmap32A( HINSTANCE32 instance, LPCSTR name )
795 if (!HIWORD(name)) res = LoadBitmap32W( instance, (LPWSTR)name );
798 LPWSTR uni = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
799 res = LoadBitmap32W( instance, uni );
800 HeapFree( GetProcessHeap(), 0, uni );
806 /***********************************************************************
807 * BITMAP_DeleteObject
809 BOOL32 BITMAP_DeleteObject( HBITMAP16 hbitmap, BITMAPOBJ * bmp )
811 #ifdef PRELIMINARY_WING16_SUPPORT
812 if( bmp->bitmap.bmBits )
813 TSXShmDetach( display, (XShmSegmentInfo*)bmp->bitmap.bmBits );
816 TSXFreePixmap( display, bmp->pixmap );
817 #ifdef PRELIMINARY_WING16_SUPPORT
818 if( bmp->bitmap.bmBits )
820 __ShmBitmapCtl* p = (__ShmBitmapCtl*)bmp->bitmap.bmBits;
821 WORD sel = HIWORD(p->bits);
822 unsigned long l, limit = GetSelectorLimit(sel);
824 for( l = 0; l < limit; l += 0x10000, sel += __AHINCR )
826 shmctl(p->si.shmid, IPC_RMID, NULL);
827 shmdt(p->si.shmaddr); /* already marked for destruction */
833 DIBSECTION *dib = bmp->dibSection;
835 if (!dib->dshSection && dib->dsBm.bmBits)
836 HeapFree(GetProcessHeap(), 0, dib->dsBm.bmBits);
838 HeapFree(GetProcessHeap(), 0, dib);
841 HeapFree(GetProcessHeap(), 0, bmp->colorMap);
843 return GDI_FreeObject( hbitmap );
847 /***********************************************************************
850 INT16 BITMAP_GetObject16( BITMAPOBJ * bmp, INT16 count, LPVOID buffer )
854 FIXME(bitmap, "not implemented for DIBs\n");
859 if (count > sizeof(bmp->bitmap)) count = sizeof(bmp->bitmap);
860 memcpy( buffer, &bmp->bitmap, count );
866 /***********************************************************************
869 INT32 BITMAP_GetObject32( BITMAPOBJ * bmp, INT32 count, LPVOID buffer )
873 if (count < sizeof(DIBSECTION))
875 if (count > sizeof(BITMAP32)) count = sizeof(BITMAP32);
879 if (count > sizeof(DIBSECTION)) count = sizeof(DIBSECTION);
882 memcpy( buffer, bmp->dibSection, count );
888 bmp32.bmType = bmp->bitmap.bmType;
889 bmp32.bmWidth = bmp->bitmap.bmWidth;
890 bmp32.bmHeight = bmp->bitmap.bmHeight;
891 bmp32.bmWidthBytes = bmp->bitmap.bmWidthBytes;
892 bmp32.bmPlanes = bmp->bitmap.bmPlanes;
893 bmp32.bmBitsPixel = bmp->bitmap.bmBitsPixel;
895 if (count > sizeof(bmp32)) count = sizeof(bmp32);
896 memcpy( buffer, &bmp32, count );
902 /***********************************************************************
903 * CreateDiscardableBitmap16 (GDI.156)
905 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width,
908 return CreateCompatibleBitmap16( hdc, width, height );
912 /******************************************************************************
913 * CreateDiscardableBitmap32 [GDI32.38] Creates a discardable bitmap
916 * Success: Handle to bitmap
919 HBITMAP32 WINAPI CreateDiscardableBitmap32(
920 HDC32 hdc, /* [in] Handle to device context */
921 INT32 width, /* [in] Bitmap width */
922 INT32 height) /* [in] Bitmap height */
924 return CreateCompatibleBitmap32( hdc, width, height );
928 /***********************************************************************
929 * GetBitmapDimensionEx16 (GDI.468)
932 * Can this call GetBitmapDimensionEx32?
934 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
936 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
937 if (!bmp) return FALSE;
939 GDI_HEAP_UNLOCK( hbitmap );
944 /******************************************************************************
945 * GetBitmapDimensionEx32 [GDI32.144] Retrieves dimensions of a bitmap
951 BOOL32 WINAPI GetBitmapDimensionEx32(
952 HBITMAP32 hbitmap, /* [in] Handle to bitmap */
953 LPSIZE32 size) /* [out] Address of struct receiving dimensions */
955 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
956 if (!bmp) return FALSE;
957 size->cx = (INT32)bmp->size.cx;
958 size->cy = (INT32)bmp->size.cy;
959 GDI_HEAP_UNLOCK( hbitmap );
964 /***********************************************************************
965 * GetBitmapDimension (GDI.162)
967 DWORD WINAPI GetBitmapDimension( HBITMAP16 hbitmap )
970 if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
971 return MAKELONG( size.cx, size.cy );
975 /***********************************************************************
976 * SetBitmapDimensionEx16 (GDI.478)
978 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y,
981 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
982 if (!bmp) return FALSE;
983 if (prevSize) *prevSize = bmp->size;
986 GDI_HEAP_UNLOCK( hbitmap );
991 /******************************************************************************
992 * SetBitmapDimensionEx32 [GDI32.304] Assignes dimensions to a bitmap
998 BOOL32 WINAPI SetBitmapDimensionEx32(
999 HBITMAP32 hbitmap, /* [in] Handle to bitmap */
1000 INT32 x, /* [in] Bitmap width */
1001 INT32 y, /* [in] Bitmap height */
1002 LPSIZE32 prevSize) /* [out] Address of structure for orig dims */
1004 BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
1005 if (!bmp) return FALSE;
1006 if (prevSize) CONV_SIZE16TO32( &bmp->size, prevSize );
1007 bmp->size.cx = (INT16)x;
1008 bmp->size.cy = (INT16)y;
1009 GDI_HEAP_UNLOCK( hbitmap );
1014 /***********************************************************************
1015 * SetBitmapDimension (GDI.163)
1017 DWORD WINAPI SetBitmapDimension( HBITMAP16 hbitmap, INT16 x, INT16 y )
1020 if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
1021 return MAKELONG( size.cx, size.cy );