Author: tkreuzer
Date: Mon Jun 7 17:55:03 2010
New Revision: 47663
URL:
http://svn.reactos.org/svn/reactos?rev=47663&view=rev
Log:
[WIN32K]
Introduce GreCreateBitmapEx, which has the extended functionality needed by some callers,
GreCreateBitmap calls GreCreateBitmapEx to keep the simple syntax. Use it in
DIB_CreateDIBSection to fix build. Also pass the size of the image (still ignored), which
is needed for compressed bitmaps (we currently assume that RLEs take as much space as an
uncompressed bitmap)
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h
branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h [iso-8859-1] Mon
Jun 7 17:55:03 2010
@@ -11,7 +11,6 @@
UINT FASTCALL BITMAP_GetRealBitsPixel(UINT nBitsPixel);
INT FASTCALL BITMAP_GetWidthBytes (INT bmWidth, INT bpp);
-
HBITMAP
APIENTRY
GreCreateBitmap(
@@ -20,3 +19,15 @@
IN UINT cPlanes,
IN UINT cBitsPixel,
IN OPTIONAL PVOID pvBits);
+
+HBITMAP
+APIENTRY
+GreCreateBitmapEx(
+ IN INT nWidth,
+ IN INT nHeight,
+ IN ULONG cjWidthBytes,
+ IN ULONG iFormat,
+ IN USHORT fjBitmap,
+ IN ULONG cjBits,
+ IN OPTIONAL PVOID pvBits);
+
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Mon
Jun 7 17:55:03 2010
@@ -69,6 +69,74 @@
HBITMAP
APIENTRY
+GreCreateBitmapEx(
+ IN INT nWidth,
+ IN INT nHeight,
+ IN ULONG cjWidthBytes,
+ IN ULONG iFormat,
+ IN USHORT fjBitmap,
+ IN ULONG cjSizeImage,
+ IN OPTIONAL PVOID pvBits)
+{
+ PSURFACE psurf;
+ SURFOBJ *pso;
+ HBITMAP hbmp;
+ PVOID pvCompressedBits;
+ SIZEL sizl;
+ FLONG fl = 0;
+
+ /* Verify format */
+ if (iFormat < BMF_1BPP || iFormat > BMF_PNG) return NULL;
+
+ /* Allocate a surface */
+ psurf = SURFACE_AllocSurface(STYPE_BITMAP, nWidth, nHeight, iFormat);
+ if (!psurf)
+ {
+ DPRINT1("SURFACE_AllocSurface failed.\n");
+ return NULL;
+ }
+
+ /* Get the handle for the bitmap and the surfobj */
+ hbmp = (HBITMAP)psurf->SurfObj.hsurf;
+ pso = &psurf->SurfObj;
+
+ /* The infamous RLE hack */
+ if (iFormat == BMF_4RLE)
+ {
+ sizl.cx = nWidth; sizl.cy = nHeight;
+ pvCompressedBits = pvBits;
+ pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
+ Decompress4bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
+ fl |= BMF_RLE_HACK;
+ }
+ else if (iFormat == BMF_8RLE)
+ {
+ sizl.cx = nWidth; sizl.cy = nHeight;
+ pvCompressedBits = pvBits;
+ pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
+ Decompress8bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
+ fl |= BMF_RLE_HACK;
+ }
+
+ /* Set the bitmap bits */
+ if (!SURFACE_bSetBitmapBits(psurf, fjBitmap, cjWidthBytes, pvBits))
+ {
+ /* Bail out if that failed */
+ DPRINT1("SURFACE_bSetBitmapBits failed.\n");
+ SURFACE_FreeSurfaceByHandle(hbmp);
+ return NULL;
+ }
+
+ /* Mark as API bitmap */
+ psurf->flags |= API_BITMAP;
+
+ /* Unlock the surface and return */
+ SURFACE_UnlockSurface(psurf);
+ return hbmp;
+}
+
+HBITMAP
+APIENTRY
GreCreateBitmap(
IN INT nWidth,
IN INT nHeight,
@@ -76,65 +144,14 @@
IN UINT cBitsPixel,
IN OPTIONAL PVOID pvBits)
{
- PSURFACE psurf;
- SURFOBJ *pso;
- HBITMAP hbmp;
- PVOID pvCompressedBits;
- SIZEL sizl;
- FLONG fl = 0;
- ULONG iFormat;
-
- /* Calculate bitmap format */
- iFormat = BitmapFormat(cBitsPixel * cPlanes, BI_RGB);
-
- /* Verify format */
- if (iFormat < BMF_1BPP || iFormat > BMF_PNG) return NULL;
-
- /* Allocate a surface */
- psurf = SURFACE_AllocSurface(STYPE_BITMAP, nWidth, nHeight, iFormat);
- if (!psurf)
- {
- DPRINT1("SURFACE_AllocSurface failed.\n");
- return NULL;
- }
-
- /* Get the handle for the bitmap and the surfobj */
- hbmp = (HBITMAP)psurf->SurfObj.hsurf;
- pso = &psurf->SurfObj;
-
- /* The infamous RLE hack */
- if (iFormat == BMF_4RLE)
- {
- sizl.cx = nWidth; sizl.cy = nHeight;
- pvCompressedBits = pvBits;
- pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
- Decompress4bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
- fl |= BMF_RLE_HACK;
- }
- else if (iFormat == BMF_8RLE)
- {
- sizl.cx = nWidth; sizl.cy = nHeight;
- pvCompressedBits = pvBits;
- pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
- Decompress8bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
- fl |= BMF_RLE_HACK;
- }
-
- /* Set the bitmap bits */
- if (!SURFACE_bSetBitmapBits(psurf, fl, 0, pvBits))
- {
- /* Bail out if that failed */
- DPRINT1("SURFACE_bSetBitmapBits failed.\n");
- SURFACE_FreeSurfaceByHandle(hbmp);
- return NULL;
- }
-
- /* Mark as API bitmap */
- psurf->flags |= API_BITMAP;
-
- /* Unlock the surface and return */
- SURFACE_UnlockSurface(psurf);
- return hbmp;
+ /* Call the extended function */
+ return GreCreateBitmapEx(nWidth,
+ nHeight,
+ 0, /* auto width */
+ BitmapFormat(cBitsPixel * cPlanes, BI_RGB),
+ 0, /* no bitmap flags */
+ 0, /* auto size */
+ pvBits);
}
HBITMAP
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Mon
Jun 7 17:55:03 2010
@@ -1492,12 +1492,14 @@
// Create Device Dependent Bitmap and add DIB pointer
Size.cx = bm.bmWidth;
Size.cy = abs(bm.bmHeight);
- res = IntCreateBitmap(Size,
- bm.bmWidthBytes,
- BitmapFormat(bi->biBitCount * bi->biPlanes,
bi->biCompression),
- BMF_DONTCACHE | BMF_USERMEM | BMF_NOZEROINIT |
- (bi->biHeight < 0 ? BMF_TOPDOWN : 0),
- bm.bmBits);
+ res = GreCreateBitmapEx(bm.bmWidth,
+ abs(bm.bmHeight),
+ bm.bmWidthBytes,
+ BitmapFormat(bi->biBitCount * bi->biPlanes,
bi->biCompression),
+ BMF_DONTCACHE | BMF_USERMEM | BMF_NOZEROINIT |
+ (bi->biHeight < 0 ? BMF_TOPDOWN : 0),
+ bi->biSizeImage,
+ bm.bmBits);
if (!res)
{
if (lpRGB != bmi->bmiColors)