diff --git a/graphics/x11drv/dib.c b/graphics/x11drv/dib.c index 8017267adf4..0761d81a20e 100644 --- a/graphics/x11drv/dib.c +++ b/graphics/x11drv/dib.c @@ -3167,10 +3167,10 @@ void X11DRV_DIB_UpdateDIBSection(DC *dc, BOOL toDIB) HBITMAP16 X11DRV_DIB_CreateDIBSection16( DC *dc, BITMAPINFO *bmi, UINT16 usage, SEGPTR *bits, HANDLE section, - DWORD offset) + DWORD offset, DWORD ovr_pitch) { HBITMAP res = X11DRV_DIB_CreateDIBSection(dc, bmi, usage, NULL, - section, offset); + section, offset, ovr_pitch); if ( res ) { BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(res, BITMAP_MAGIC); @@ -3272,7 +3272,7 @@ extern BOOL X11DRV_XShmCreateImage(XImage** image, int width, int height, int bp HBITMAP X11DRV_DIB_CreateDIBSection( DC *dc, BITMAPINFO *bmi, UINT usage, LPVOID *bits, HANDLE section, - DWORD offset) + DWORD offset, DWORD ovr_pitch) { HBITMAP res = 0; BITMAPOBJ *bmp = NULL; @@ -3293,7 +3293,8 @@ HBITMAP X11DRV_DIB_CreateDIBSection( bm.bmType = 0; bm.bmWidth = bi->biWidth; bm.bmHeight = effHeight; - bm.bmWidthBytes = DIB_GetDIBWidthBytes(bm.bmWidth, bi->biBitCount); + bm.bmWidthBytes = ovr_pitch ? ovr_pitch + : DIB_GetDIBWidthBytes(bm.bmWidth, bi->biBitCount); bm.bmPlanes = bi->biPlanes; bm.bmBitsPixel = bi->biBitCount; bm.bmBits = NULL; @@ -3304,9 +3305,13 @@ HBITMAP X11DRV_DIB_CreateDIBSection( if (section) bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS, 0L, offset, totalSize); - else + else if (ovr_pitch && offset) + bm.bmBits = offset; + else { + offset = 0; bm.bmBits = VirtualAlloc(NULL, totalSize, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + } /* Create Color Map */ if (bm.bmBits && bm.bmBitsPixel <= 8) @@ -3396,7 +3401,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection( { if (section) UnmapViewOfFile(bm.bmBits), bm.bmBits = NULL; - else + else if (!offset) VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL; } @@ -3411,8 +3416,16 @@ HBITMAP X11DRV_DIB_CreateDIBSection( { if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, (LPVOID)res)) { - X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY ); - if (dib) dib->status = X11DRV_DIB_InSync; + if (section || offset) + { + X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE ); + if (dib) dib->status = X11DRV_DIB_AppMod; + } + else + { + X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY ); + if (dib) dib->status = X11DRV_DIB_InSync; + } } } diff --git a/include/bitmap.h b/include/bitmap.h index 4d171fb9bee..d8ed08b5dc0 100644 --- a/include/bitmap.h +++ b/include/bitmap.h @@ -52,6 +52,8 @@ extern int DIB_GetDIBImageBytes( int width, int height, int depth ); extern int DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse ); extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width, int *height, WORD *bpp, WORD *compr ); +extern HBITMAP DIB_CreateDIBSection( HDC hdc, BITMAPINFO *bmi, UINT usage, LPVOID *bits, + HANDLE section, DWORD offset, DWORD ovr_pitch ); extern void DIB_UpdateDIBSection( DC *dc, BOOL toDIB ); extern void DIB_DeleteDIBSection( BITMAPOBJ *bmp ); extern void DIB_SelectDIBSection( DC *dc, BITMAPOBJ *bmp ); diff --git a/include/gdi.h b/include/gdi.h index 6a9ce2bdf09..f21213fce8e 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -181,9 +181,9 @@ typedef struct tagDC_FUNCS BOOL (*pCreateBitmap)(HBITMAP); BOOL (*pCreateDC)(DC*,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*); HBITMAP (*pCreateDIBSection)(DC *,BITMAPINFO *,UINT,LPVOID *,HANDLE, - DWORD); + DWORD,DWORD); HBITMAP16 (*pCreateDIBSection16)(DC *,BITMAPINFO *,UINT16,SEGPTR *,HANDLE, - DWORD); + DWORD,DWORD); BOOL (*pDeleteDC)(DC*); BOOL (*pDeleteObject)(HGDIOBJ); DWORD (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA); diff --git a/include/x11drv.h b/include/x11drv.h index 26e48a6923a..3a2bd4997b3 100644 --- a/include/x11drv.h +++ b/include/x11drv.h @@ -254,9 +254,9 @@ extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse, extern void X11DRV_DIB_UpdateDIBSection(struct tagDC *dc, BOOL toDIB); extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage, - LPVOID *bits, HANDLE section, DWORD offset); + LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch); extern HBITMAP16 X11DRV_DIB_CreateDIBSection16(struct tagDC *dc, BITMAPINFO *bmi, UINT16 usage, - SEGPTR *bits, HANDLE section, DWORD offset); + SEGPTR *bits, HANDLE section, DWORD offset, DWORD ovr_pitch); extern struct tagBITMAP_DRIVER X11DRV_BITMAP_Driver; diff --git a/objects/dib.c b/objects/dib.c index b346629d6bc..0640bb9fa66 100644 --- a/objects/dib.c +++ b/objects/dib.c @@ -870,7 +870,26 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage, if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); if(!dc) return (HBITMAP16) NULL; - hbitmap = dc->funcs->pCreateDIBSection16(dc, bmi, usage, bits, section, offset); + hbitmap = dc->funcs->pCreateDIBSection16(dc, bmi, usage, bits, section, offset, 0); + + GDI_HEAP_UNLOCK(hdc); + + return hbitmap; +} + +/*********************************************************************** + * DIB_CreateDIBSection + */ +HBITMAP DIB_CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage, + LPVOID *bits, HANDLE section, + DWORD offset, DWORD ovr_pitch) +{ + HBITMAP hbitmap; + DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC); + if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if(!dc) return (HBITMAP) NULL; + + hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset, ovr_pitch); GDI_HEAP_UNLOCK(hdc); @@ -884,16 +903,7 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage, LPVOID *bits, HANDLE section, DWORD offset) { - HBITMAP hbitmap; - DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC); - if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); - if(!dc) return (HBITMAP) NULL; - - hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset); - - GDI_HEAP_UNLOCK(hdc); - - return hbitmap; + return DIB_CreateDIBSection(hdc, bmi, usage, bits, section, offset, 0); } /*********************************************************************** @@ -909,7 +919,7 @@ void DIB_DeleteDIBSection( BITMAPOBJ *bmp ) { if (dib->dshSection) UnmapViewOfFile(dib->dsBm.bmBits); - else + else if (!dib->dsOffset) VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE ); }