More bitmap fixes.
This commit is contained in:
parent
463b713dfd
commit
82617362a5
|
@ -17,13 +17,6 @@
|
|||
#include "xmalloc.h"
|
||||
#include "x11drv.h"
|
||||
|
||||
#ifdef PRELIMINARY_WING16_SUPPORT
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* GCs used for B&W and color bitmap operations */
|
||||
GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
|
||||
|
||||
|
@ -186,11 +179,14 @@ BOOL32 X11DRV_CreateBitmap( HBITMAP32 hbitmap )
|
|||
/* Check parameters */
|
||||
if (bmp->bitmap.bmPlanes != 1) return 0;
|
||||
if ((bmp->bitmap.bmBitsPixel != 1) &&
|
||||
(bmp->bitmap.bmBitsPixel != screenDepth)) {
|
||||
(bmp->bitmap.bmBitsPixel != screenDepth)) {
|
||||
GDI_HEAP_UNLOCK( hbitmap );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TRACE(x11drv, "(%08x) %dx%d %d bpp\n", hbitmap, bmp->bitmap.bmWidth,
|
||||
bmp->bitmap.bmHeight, bmp->bitmap.bmBitsPixel);
|
||||
|
||||
pbitmap = X11DRV_AllocBitmap( bmp );
|
||||
if(!pbitmap) return FALSE;
|
||||
|
||||
|
@ -243,7 +239,9 @@ static LONG X11DRV_GetBitmapBits(BITMAPOBJ *bmp, void *buffer, LONG count)
|
|||
LPBYTE tbuf;
|
||||
int h, w, pad;
|
||||
|
||||
pad = BITMAP_GetBitsPadding(bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel);
|
||||
TRACE(x11drv, "(bmp=%p, buffer=%p, count=%lx)\n", bmp, buffer, count);
|
||||
|
||||
pad = BITMAP_GetPadding(bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel);
|
||||
|
||||
if (pad == -1)
|
||||
return 0;
|
||||
|
@ -364,30 +362,25 @@ static LONG X11DRV_SetBitmapBits(BITMAPOBJ *bmp, void *bits, LONG count)
|
|||
struct XPutImage_descr descr;
|
||||
LONG height;
|
||||
XImage *image;
|
||||
LPBYTE sbuf, tmpbuffer;
|
||||
int w, h, pad, widthbytes;
|
||||
LPBYTE sbuf;
|
||||
int w, h, pad;
|
||||
|
||||
TRACE(x11drv, "(bmp=%p, bits=%p, count=%lx)\n", bmp, bits, count);
|
||||
|
||||
pad = BITMAP_GetBitsPadding(bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel);
|
||||
pad = BITMAP_GetPadding(bmp->bitmap.bmWidth, bmp->bitmap.bmBitsPixel);
|
||||
|
||||
if (pad == -1)
|
||||
return 0;
|
||||
|
||||
sbuf = (LPBYTE)bits;
|
||||
|
||||
widthbytes = (((bmp->bitmap.bmWidth * bmp->bitmap.bmBitsPixel) + 31) /
|
||||
32) * 4;
|
||||
height = count / bmp->bitmap.bmWidthBytes;
|
||||
tmpbuffer = (LPBYTE)xmalloc(widthbytes*height);
|
||||
|
||||
TRACE(x11drv, "h=%ld, w=%d, wb=%d\n", height, bmp->bitmap.bmWidth,
|
||||
widthbytes);
|
||||
height = count / bmp->bitmap.bmWidthBytes;
|
||||
|
||||
EnterCriticalSection( &X11DRV_CritSection );
|
||||
image = XCreateImage( display, DefaultVisualOfScreen(screen),
|
||||
bmp->bitmap.bmBitsPixel, ZPixmap, 0, tmpbuffer,
|
||||
bmp->bitmap.bmWidth,height,32,widthbytes );
|
||||
bmp->bitmap.bmBitsPixel, ZPixmap, 0, NULL,
|
||||
bmp->bitmap.bmWidth, height, 32, 0 );
|
||||
image->data = (LPBYTE)xmalloc(image->bytes_per_line * height);
|
||||
|
||||
/* copy 16 bit padded image buffer with real bitsperpixel to XImage */
|
||||
sbuf = (LPBYTE)bits;
|
||||
|
@ -466,8 +459,9 @@ static LONG X11DRV_SetBitmapBits(BITMAPOBJ *bmp, void *bits, LONG count)
|
|||
descr.image = image;
|
||||
descr.width = bmp->bitmap.bmWidth;
|
||||
descr.height = height;
|
||||
|
||||
CALL_LARGE_STACK( XPutImage_wrapper, &descr );
|
||||
XDestroyImage( image ); /* frees tmpbuffer too */
|
||||
XDestroyImage( image ); /* frees image->data too */
|
||||
LeaveCriticalSection( &X11DRV_CritSection );
|
||||
|
||||
return count;
|
||||
|
@ -505,28 +499,8 @@ BOOL32 X11DRV_BITMAP_DeleteObject( HBITMAP32 hbitmap, BITMAPOBJ * bmp )
|
|||
{
|
||||
X11DRV_PHYSBITMAP *pbitmap = bmp->DDBitmap->physBitmap;
|
||||
|
||||
#ifdef PRELIMINARY_WING16_SUPPORT
|
||||
if( bmp->bitmap.bmBits )
|
||||
TSXShmDetach( display, (XShmSegmentInfo*)bmp->bitmap.bmBits );
|
||||
#endif
|
||||
|
||||
TSXFreePixmap( display, pbitmap->pixmap );
|
||||
|
||||
|
||||
#ifdef PRELIMINARY_WING16_SUPPORT
|
||||
if( bmp->bitmap.bmBits )
|
||||
{
|
||||
__ShmBitmapCtl* p = (__ShmBitmapCtl*)bmp->bitmap.bmBits;
|
||||
WORD sel = HIWORD(p->bits);
|
||||
unsigned long l, limit = GetSelectorLimit(sel);
|
||||
|
||||
for( l = 0; l < limit; l += 0x10000, sel += __AHINCR )
|
||||
FreeSelector(sel);
|
||||
shmctl(p->si.shmid, IPC_RMID, NULL);
|
||||
shmdt(p->si.shmaddr); /* already marked for destruction */
|
||||
}
|
||||
#endif
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, bmp->DDBitmap->physBitmap );
|
||||
HeapFree( GetProcessHeap(), 0, bmp->DDBitmap );
|
||||
bmp->DDBitmap = NULL;
|
||||
|
|
|
@ -53,16 +53,12 @@ typedef struct tagBITMAPOBJ
|
|||
|
||||
} BITMAPOBJ;
|
||||
|
||||
#define BITMAP_WIDTH_BYTES(width,bpp) \
|
||||
(((bpp) == 24) ? (width) * 4 : ( ((bpp) == 15) ? (width) * 2 : \
|
||||
((width) * (bpp) + 15) / 16 * 2 ))
|
||||
|
||||
/* objects/bitmap.c */
|
||||
extern INT16 BITMAP_GetObject16( BITMAPOBJ * bmp, INT16 count, LPVOID buffer );
|
||||
extern INT32 BITMAP_GetObject32( BITMAPOBJ * bmp, INT32 count, LPVOID buffer );
|
||||
extern BOOL32 BITMAP_DeleteObject( HBITMAP16 hbitmap, BITMAPOBJ * bitmap );
|
||||
extern INT32 BITMAP_GetBitsPadding( int width, int depth );
|
||||
extern INT32 BITMAP_GetBitsWidth( int width, int depth );
|
||||
extern INT32 BITMAP_GetPadding( INT32 width, INT32 depth );
|
||||
extern INT32 BITMAP_GetWidthBytes( INT32 width, INT32 depth );
|
||||
extern HBITMAP32 BITMAP_LoadBitmap32W(HINSTANCE32 instance,LPCWSTR name,
|
||||
UINT32 loadflags);
|
||||
extern HBITMAP32 BITMAP_CopyBitmap( HBITMAP32 hbitmap );
|
||||
|
|
|
@ -19,19 +19,18 @@
|
|||
|
||||
|
||||
/***********************************************************************
|
||||
* BITMAP_GetBitsPadding
|
||||
* BITMAP_GetPadding
|
||||
*
|
||||
* Return number of bytes to pad a scanline of 16-bit aligned Windows DDB data.
|
||||
*/
|
||||
INT32 BITMAP_GetBitsPadding( int bmWidth, int bpp )
|
||||
INT32 BITMAP_GetPadding( int bmWidth, int bpp )
|
||||
{
|
||||
INT32 pad;
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
case 1:
|
||||
if (!(bmWidth & 15)) pad = 0;
|
||||
else pad = ((16 - (bmWidth & 15)) + 7) / 8;
|
||||
pad = ((bmWidth-1) & 8) ? 0 : 1;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
@ -61,11 +60,12 @@ INT32 BITMAP_GetBitsPadding( int bmWidth, int bpp )
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* BITMAP_GetBitsWidth
|
||||
* BITMAP_GetWidthBytes
|
||||
*
|
||||
* Return number of bytes taken by a scanline of 16-bit aligned Windows DDB data.
|
||||
* Return number of bytes taken by a scanline of 16-bit aligned Windows DDB
|
||||
* data.
|
||||
*/
|
||||
INT32 BITMAP_GetBitsWidth( int bmWidth, int bpp )
|
||||
INT32 BITMAP_GetWidthBytes( INT32 bmWidth, INT32 bpp )
|
||||
{
|
||||
switch(bpp)
|
||||
{
|
||||
|
@ -167,11 +167,11 @@ HBITMAP32 WINAPI CreateBitmap32( INT32 width, INT32 height, UINT32 planes,
|
|||
bmp->size.cx = 0;
|
||||
bmp->size.cy = 0;
|
||||
bmp->bitmap.bmType = 0;
|
||||
bmp->bitmap.bmWidth = (INT16)width;
|
||||
bmp->bitmap.bmHeight = (INT16)height;
|
||||
bmp->bitmap.bmPlanes = (BYTE)planes;
|
||||
bmp->bitmap.bmBitsPixel = (BYTE)bpp;
|
||||
bmp->bitmap.bmWidthBytes = (INT16)BITMAP_WIDTH_BYTES( width, bpp );
|
||||
bmp->bitmap.bmWidth = width;
|
||||
bmp->bitmap.bmHeight = height;
|
||||
bmp->bitmap.bmPlanes = planes;
|
||||
bmp->bitmap.bmBitsPixel = bpp;
|
||||
bmp->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
|
||||
bmp->bitmap.bmBits = NULL;
|
||||
|
||||
bmp->DDBitmap = NULL;
|
||||
|
@ -594,8 +594,11 @@ HBITMAP16 WINAPI LoadBitmap16( HINSTANCE16 instance, SEGPTR name )
|
|||
}
|
||||
|
||||
|
||||
HBITMAP32 BITMAP_LoadBitmap32W(HINSTANCE32 instance,LPCWSTR name,
|
||||
UINT32 loadflags)
|
||||
/**********************************************************************
|
||||
* BITMAP_LoadBitmap32W
|
||||
*/
|
||||
HBITMAP32 BITMAP_LoadBitmap32W(HINSTANCE32 instance,LPCWSTR name,
|
||||
UINT32 loadflags)
|
||||
{
|
||||
HBITMAP32 hbitmap = 0;
|
||||
HDC32 hdc;
|
||||
|
@ -647,6 +650,8 @@ HBITMAP32 BITMAP_LoadBitmap32W(HINSTANCE32 instance,LPCWSTR name,
|
|||
if (loadflags & LR_LOADFROMFILE) UnmapViewOfFile( ptr );
|
||||
return hbitmap;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* LoadBitmap32W [USER32.358] Loads bitmap from the executable file
|
||||
*
|
||||
|
|
|
@ -754,8 +754,8 @@ HCURSOR16 CURSORICON_IconToCursor(HICON16 hIcon, BOOL32 bSemiTransparent)
|
|||
TRACE(icon, "[%04x] %ix%i %ibpp (bogus %ibps)\n",
|
||||
hIcon, pIcon->nWidth, pIcon->nHeight, pIcon->bBitsPerPixel, pIcon->nWidthBytes );
|
||||
|
||||
xor_width = BITMAP_GetBitsWidth( pIcon->nWidth, bpp );
|
||||
and_width = BITMAP_GetBitsWidth( pIcon->nWidth, 1 );
|
||||
xor_width = BITMAP_GetWidthBytes( pIcon->nWidth, bpp );
|
||||
and_width = BITMAP_GetWidthBytes( pIcon->nWidth, 1 );
|
||||
psPtr = (BYTE *)(pIcon + 1) + pIcon->nHeight * and_width;
|
||||
|
||||
memset(pXorBits, 0, 128);
|
||||
|
@ -923,9 +923,9 @@ HGLOBAL16 WINAPI CreateCursorIconIndirect( HINSTANCE16 hInstance,
|
|||
|
||||
hInstance = GetExePtr( hInstance ); /* Make it a module handle */
|
||||
if (!lpXORbits || !lpANDbits || info->bPlanes != 1) return 0;
|
||||
info->nWidthBytes = BITMAP_WIDTH_BYTES(info->nWidth,info->bBitsPerPixel);
|
||||
info->nWidthBytes = BITMAP_GetWidthBytes(info->nWidth,info->bBitsPerPixel);
|
||||
sizeXor = info->nHeight * info->nWidthBytes;
|
||||
sizeAnd = info->nHeight * BITMAP_WIDTH_BYTES( info->nWidth, 1 );
|
||||
sizeAnd = info->nHeight * BITMAP_GetWidthBytes( info->nWidth, 1 );
|
||||
if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
|
||||
sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
|
||||
return 0;
|
||||
|
@ -1057,7 +1057,7 @@ BOOL32 WINAPI DrawIcon32( HDC32 hdc, INT32 x, INT32 y, HICON32 hIcon )
|
|||
(char *)(ptr+1) );
|
||||
hXorBits = CreateBitmap32( ptr->nWidth, ptr->nHeight, ptr->bPlanes,
|
||||
ptr->bBitsPerPixel, (char *)(ptr + 1)
|
||||
+ ptr->nHeight * BITMAP_WIDTH_BYTES(ptr->nWidth,1) );
|
||||
+ ptr->nHeight * BITMAP_GetWidthBytes(ptr->nWidth,1) );
|
||||
oldFg = SetTextColor32( hdc, RGB(0,0,0) );
|
||||
oldBg = SetBkColor32( hdc, RGB(255,255,255) );
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ DWORD WINAPI DumpIcon( SEGPTR pInfo, WORD *lpLen,
|
|||
|
||||
if (!info) return 0;
|
||||
sizeXor = info->nHeight * info->nWidthBytes;
|
||||
sizeAnd = info->nHeight * BITMAP_WIDTH_BYTES( info->nWidth, 1 );
|
||||
sizeAnd = info->nHeight * BITMAP_GetWidthBytes( info->nWidth, 1 );
|
||||
if (lpAndBits) *lpAndBits = pInfo + sizeof(CURSORICONINFO);
|
||||
if (lpXorBits) *lpXorBits = pInfo + sizeof(CURSORICONINFO) + sizeAnd;
|
||||
if (lpLen) *lpLen = sizeof(CURSORICONINFO) + sizeAnd + sizeXor;
|
||||
|
@ -1674,8 +1674,7 @@ BOOL32 WINAPI GetIconInfo(HICON32 hIcon,LPICONINFO iconinfo) {
|
|||
ciconinfo->bPlanes, ciconinfo->bBitsPerPixel,
|
||||
(char *)(ciconinfo + 1)
|
||||
+ ciconinfo->nHeight *
|
||||
BITMAP_GetBitsWidth (ciconinfo->nWidth,1) );
|
||||
// BITMAP_WIDTH_BYTES(ciconinfo->nWidth,1) );
|
||||
BITMAP_GetWidthBytes (ciconinfo->nWidth,1) );
|
||||
iconinfo->hbmMask = CreateBitmap32 ( ciconinfo->nWidth, ciconinfo->nHeight,
|
||||
1, 1, (char *)(ciconinfo + 1));
|
||||
|
||||
|
@ -1819,7 +1818,7 @@ BOOL32 WINAPI DrawIconEx32( HDC32 hdc, INT32 x0, INT32 y0, HICON32 hIcon,
|
|||
ptr->bPlanes, ptr->bBitsPerPixel,
|
||||
(char *)(ptr + 1)
|
||||
+ ptr->nHeight *
|
||||
BITMAP_WIDTH_BYTES(ptr->nWidth,1) );
|
||||
BITMAP_GetWidthBytes(ptr->nWidth,1) );
|
||||
hAndBits = CreateBitmap32 ( ptr->nWidth, ptr->nHeight,
|
||||
1, 1, (char *)(ptr+1) );
|
||||
oldFg = SetTextColor32( hdc, RGB(0,0,0) );
|
||||
|
|
|
@ -332,7 +332,7 @@ static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
|
|||
bmpObjPtr->bitmap.bmType = 0;
|
||||
bmpObjPtr->bitmap.bmWidth = width;
|
||||
bmpObjPtr->bitmap.bmHeight = height;
|
||||
bmpObjPtr->bitmap.bmWidthBytes = BITMAP_WIDTH_BYTES( width, bpp );
|
||||
bmpObjPtr->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
|
||||
bmpObjPtr->bitmap.bmPlanes = 1;
|
||||
bmpObjPtr->bitmap.bmBitsPixel = bpp;
|
||||
bmpObjPtr->bitmap.bmBits = NULL;
|
||||
|
@ -476,7 +476,8 @@ HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL32 fCursor )
|
|||
bmpXor = (BITMAPOBJ *) GDI_GetObjPtr( descr.bitmap, BITMAP_MAGIC );
|
||||
bmpAnd = (BITMAPOBJ *) GDI_GetObjPtr( descr.mask, BITMAP_MAGIC );
|
||||
sizeXor = bmpXor->bitmap.bmHeight * bmpXor->bitmap.bmWidthBytes;
|
||||
sizeAnd = bmpXor->bitmap.bmHeight * BITMAP_WIDTH_BYTES( bmpXor->bitmap.bmWidth, 1 );
|
||||
sizeAnd = bmpXor->bitmap.bmHeight *
|
||||
BITMAP_GetWidthBytes( bmpXor->bitmap.bmWidth, 1 );
|
||||
|
||||
if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
|
||||
sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
|
||||
|
|
Loading…
Reference in New Issue