mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 06:01:21 +00:00
[WIN32K]: Revert accidental changes to IntCreateBitmap.
svn path=/trunk/; revision=46111
This commit is contained in:
parent
7d54007084
commit
a17ba7f9af
1 changed files with 85 additions and 76 deletions
|
@ -332,108 +332,117 @@ IntCreateBitmap(IN SIZEL Size,
|
||||||
IN ULONG Flags,
|
IN ULONG Flags,
|
||||||
IN PVOID Bits)
|
IN PVOID Bits)
|
||||||
{
|
{
|
||||||
|
HBITMAP hbmp;
|
||||||
SURFOBJ *pso;
|
SURFOBJ *pso;
|
||||||
PSURFACE psurf;
|
PSURFACE psurf;
|
||||||
SIZEL LocalSize;
|
PVOID UncompressedBits;
|
||||||
ULONG ScanLine = 0; // Compiler is dumb
|
ULONG UncompressedFormat;
|
||||||
ULONG BitsSize;
|
|
||||||
|
|
||||||
ScanLine = abs(Width);
|
|
||||||
|
|
||||||
/* Does the device manage its own surface? */
|
if (Format == 0)
|
||||||
if (!Bits)
|
return 0;
|
||||||
|
|
||||||
|
psurf = SURFACE_AllocSurfaceWithHandle();
|
||||||
|
if (psurf == NULL)
|
||||||
{
|
{
|
||||||
/* The height times the bytes for each scanline */
|
return 0;
|
||||||
BitsSize = Size.cy * ScanLine;
|
}
|
||||||
if (BitsSize)
|
hbmp = psurf->BaseObject.hHmgr;
|
||||||
|
|
||||||
|
if (! SURFACE_InitBitsLock(psurf))
|
||||||
|
{
|
||||||
|
SURFACE_UnlockSurface(psurf);
|
||||||
|
SURFACE_FreeSurfaceByHandle(hbmp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pso = &psurf->SurfObj;
|
||||||
|
|
||||||
|
if (Format == BMF_4RLE)
|
||||||
|
{
|
||||||
|
pso->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_4BPP));
|
||||||
|
pso->cjBits = pso->lDelta * Size.cy;
|
||||||
|
UncompressedFormat = BMF_4BPP;
|
||||||
|
UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
|
||||||
|
Decompress4bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, pso->lDelta);
|
||||||
|
}
|
||||||
|
else if (Format == BMF_8RLE)
|
||||||
|
{
|
||||||
|
pso->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_8BPP));
|
||||||
|
pso->cjBits = pso->lDelta * Size.cy;
|
||||||
|
UncompressedFormat = BMF_8BPP;
|
||||||
|
UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
|
||||||
|
Decompress8bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, pso->lDelta);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pso->lDelta = abs(Width);
|
||||||
|
pso->cjBits = pso->lDelta * Size.cy;
|
||||||
|
UncompressedBits = Bits;
|
||||||
|
UncompressedFormat = Format;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UncompressedBits != NULL)
|
||||||
|
{
|
||||||
|
pso->pvBits = UncompressedBits;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pso->cjBits == 0)
|
||||||
{
|
{
|
||||||
/* Check for allocation flag */
|
pso->pvBits = NULL;
|
||||||
if (Flags & BMF_USERMEM)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (0 != (Flags & BMF_USERMEM))
|
||||||
{
|
{
|
||||||
/* Get the bits from user-mode memory */
|
pso->pvBits = EngAllocUserMem(pso->cjBits, 0);
|
||||||
Bits = EngAllocUserMem(BitsSize, 'mbuG');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Get kernel bits (zeroed out if requested) */
|
pso->pvBits = EngAllocMem(0 != (Flags & BMF_NOZEROINIT) ?
|
||||||
Bits = EngAllocMem((Flags & BMF_NOZEROINIT) ? 0 : FL_ZERO_MEMORY,
|
0 : FL_ZERO_MEMORY,
|
||||||
BitsSize,
|
pso->cjBits, TAG_DIB);
|
||||||
TAG_DIB);
|
}
|
||||||
|
if (pso->pvBits == NULL)
|
||||||
|
{
|
||||||
|
SURFACE_UnlockSurface(psurf);
|
||||||
|
SURFACE_FreeSurfaceByHandle(hbmp);
|
||||||
|
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bail out if that failed */
|
|
||||||
if (!Bits) return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (0 == (Flags & BMF_TOPDOWN))
|
||||||
|
{
|
||||||
|
pso->pvScan0 = (PVOID)((ULONG_PTR)pso->pvBits + pso->cjBits - pso->lDelta);
|
||||||
|
pso->lDelta = - pso->lDelta;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Should not have asked for user memory */
|
|
||||||
// ASSERT((Flags & BMF_USERMEM) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate the actual surface object structure */
|
|
||||||
psurf = SURFACE_AllocSurfaceWithHandle();
|
|
||||||
if (!psurf) return NULL;
|
|
||||||
|
|
||||||
/* Lock down the surface */
|
|
||||||
if (!SURFACE_InitBitsLock(psurf))
|
|
||||||
{
|
|
||||||
/* Bail out if that failed */
|
|
||||||
SURFACE_UnlockSurface(psurf);
|
|
||||||
SURFACE_FreeSurface(psurf);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We should now have our surface object */
|
|
||||||
pso = &psurf->SurfObj;
|
|
||||||
|
|
||||||
/* Set bits */
|
|
||||||
pso->pvBits = Bits;
|
|
||||||
|
|
||||||
/* Number of bits is based on the height times the scanline */
|
|
||||||
pso->cjBits = Size.cy * ScanLine;
|
|
||||||
if (Flags & BMF_TOPDOWN)
|
|
||||||
{
|
|
||||||
/* For topdown, the base address starts with the bits */
|
|
||||||
pso->pvScan0 = pso->pvBits;
|
pso->pvScan0 = pso->pvBits;
|
||||||
pso->lDelta = ScanLine;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Otherwise we start with the end and go up */
|
|
||||||
pso->pvScan0 = (PVOID)((ULONG_PTR)pso->pvBits + pso->cjBits - ScanLine);
|
|
||||||
pso->lDelta = -ScanLine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save format and flags */
|
pso->dhsurf = 0; /* device managed surface */
|
||||||
pso->iBitmapFormat = Format;
|
pso->hsurf = (HSURF)hbmp;
|
||||||
pso->fjBitmap = Flags & (BMF_TOPDOWN | BMF_UMPDMEM | BMF_USERMEM);
|
|
||||||
|
|
||||||
/* Save size and type */
|
|
||||||
LocalSize.cx = Size.cx;
|
|
||||||
LocalSize.cy = Size.cy;
|
|
||||||
pso->sizlBitmap = Size;
|
|
||||||
pso->iType = STYPE_BITMAP;
|
|
||||||
|
|
||||||
/* Device-managed surface, no flags or dimension */
|
|
||||||
pso->dhsurf = 0;
|
|
||||||
pso->dhpdev = NULL;
|
pso->dhpdev = NULL;
|
||||||
pso->hdev = NULL;
|
pso->hdev = NULL;
|
||||||
|
pso->sizlBitmap = Size;
|
||||||
|
pso->iBitmapFormat = UncompressedFormat;
|
||||||
|
pso->iType = STYPE_BITMAP;
|
||||||
|
pso->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
|
||||||
|
pso->iUniq = 0;
|
||||||
|
|
||||||
|
psurf->flHooks = 0;
|
||||||
psurf->flFlags = 0;
|
psurf->flFlags = 0;
|
||||||
psurf->dimension.cx = 0;
|
psurf->dimension.cx = 0;
|
||||||
psurf->dimension.cy = 0;
|
psurf->dimension.cy = 0;
|
||||||
|
|
||||||
psurf->hSecure = NULL;
|
psurf->hSecure = NULL;
|
||||||
psurf->hDIBSection = NULL;
|
psurf->hDIBSection = NULL;
|
||||||
psurf->flHooks = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/* Finally set the handle and uniq */
|
|
||||||
pso->hsurf = (HSURF)psurf->BaseObject.hHmgr;
|
|
||||||
pso->iUniq = 0;
|
|
||||||
|
|
||||||
/* Unlock and return the surface */
|
|
||||||
SURFACE_UnlockSurface(psurf);
|
SURFACE_UnlockSurface(psurf);
|
||||||
return pso->hsurf;
|
|
||||||
|
return hbmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Name gleaned from C++ symbol information for SURFMEM::bInitDIB */
|
/* Name gleaned from C++ symbol information for SURFMEM::bInitDIB */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue