- implement CreateBitmapIndirect, calling NtGdicreateBitmap

- NtGdiCreateBitmap: directly do the job instead of calling IntCreateBitmapIndirect
- remove IntCreateBitmapIndirect
- remove NtGdiCreateBitmapIndirect
- update ntgdibad.h

svn path=/trunk/; revision=27851
This commit is contained in:
Timo Kreuzer 2007-07-26 15:20:29 +00:00
parent bc4b14c9c4
commit ca6fc5cff9
5 changed files with 42 additions and 73 deletions

View file

@ -48,7 +48,7 @@ CopyEnhMetaFileW@8
CopyMetaFileA@8
CopyMetaFileW@8
CreateBitmap@20=NtGdiCreateBitmap@20
CreateBitmapIndirect@4=NtGdiCreateBitmapIndirect@4
CreateBitmapIndirect@4
CreateBrushIndirect@4
CreateColorSpaceA@4
CreateColorSpaceW@4

View file

@ -84,3 +84,20 @@ StretchBlt(
return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest,
nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, dwRop, 0, 0);
}
/*
* @implemented
*/
HBITMAP WINAPI
CreateBitmapIndirect(const BITMAP *pbm)
{
if (pbm)
{
return NtGdiCreateBitmap(pbm->bmWidth,
pbm->bmHeight,
pbm->bmPlanes,
pbm->bmBitsPixel,
pbm->bmBits);
}
return NULL;
}

View file

@ -194,13 +194,6 @@ NtGdiCopyMetaFile (
LPCWSTR File
);
/* Use NtGdiCreateBitmap and expand the pbm-> */
HBITMAP
STDCALL
NtGdiCreateBitmapIndirect (
CONST BITMAP * BM
);
/* Use NtGdiCreateDIBitmapInternal */
HBITMAP
STDCALL

View file

@ -400,36 +400,42 @@ done:
return Ret;
}
static HBITMAP
IntCreateBitmapIndirect(CONST BITMAP *BM)
HBITMAP STDCALL
NtGdiCreateBitmap(
INT Width,
INT Height,
UINT Planes,
UINT BitsPixel,
IN OPTIONAL LPBYTE Bits)
{
PBITMAPOBJ bmp;
HBITMAP hBitmap;
SIZEL Size;
UINT BitsPixel;
LONG WidthBytes;
/* NOTE: Windows also doesn't store nr. of planes separately! */
BitsPixel = BM->bmBitsPixel * BM->bmPlanes;
BitsPixel = BitsPixel * Planes;
WidthBytes = BITMAPOBJ_GetWidthBytes(Width, BitsPixel);
/* Check parameters */
if (0 == BM->bmHeight || 0 == BM->bmWidth)
if (0 == Height || 0 == Width)
{
Size.cx = Size.cy = 1;
}
else
{
Size.cx = abs(BM->bmWidth);
Size.cy = abs(BM->bmHeight);
Size.cx = abs(Width);
Size.cy = abs(Height);
}
/* Create the bitmap object. */
hBitmap = IntCreateBitmap(Size, BM->bmWidthBytes,
hBitmap = IntCreateBitmap(Size, WidthBytes,
BitmapFormat(BitsPixel, BI_RGB),
(BM->bmHeight < 0 ? BMF_TOPDOWN : 0) |
(NULL == BM->bmBits ? 0 : BMF_NOZEROINIT), NULL);
(Height < 0 ? BMF_TOPDOWN : 0) |
(NULL == Bits ? 0 : BMF_NOZEROINIT), NULL);
if (!hBitmap)
{
DPRINT("NtGdiCreateBitmap: IntCreateBitmap returned 0\n");
DPRINT("NtGdiCreateBitmap: returned 0\n");
return 0;
}
@ -452,35 +458,14 @@ IntCreateBitmapIndirect(CONST BITMAP *BM)
* to us it should be safe.
*/
if (NULL != BM->bmBits)
if (NULL != Bits)
{
NtGdiSetBitmapBits(hBitmap, bmp->SurfObj.cjBits, BM->bmBits);
NtGdiSetBitmapBits(hBitmap, bmp->SurfObj.cjBits, Bits);
}
return hBitmap;
}
HBITMAP STDCALL
NtGdiCreateBitmap(
INT Width,
INT Height,
UINT Planes,
UINT BitsPixel,
IN OPTIONAL LPBYTE Bits)
{
BITMAP BM;
BM.bmType = 0;
BM.bmWidth = Width;
BM.bmHeight = Height;
BM.bmWidthBytes = BITMAPOBJ_GetWidthBytes(Width, Planes * BitsPixel);
BM.bmPlanes = Planes;
BM.bmBitsPixel = BitsPixel;
BM.bmBits = Bits;
return IntCreateBitmapIndirect(&BM);
}
BOOL INTERNAL_CALL
BITMAP_Cleanup(PVOID ObjectBody)
{
@ -569,35 +554,6 @@ NtGdiCreateCompatibleBitmap(
return Bmp;
}
HBITMAP STDCALL
NtGdiCreateBitmapIndirect(CONST BITMAP *UnsafeBM)
{
BITMAP BM;
NTSTATUS Status = STATUS_SUCCESS;
_SEH_TRY
{
ProbeForRead(UnsafeBM, sizeof(BITMAP), 1);
BM = *UnsafeBM;
if (NULL != BM.bmBits)
{
ProbeForRead(BM.bmBits, BM.bmWidthBytes * abs(BM.bmHeight), 2);
}
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return NULL;
}
return IntCreateBitmapIndirect(&BM);
}
HBITMAP STDCALL
NtGdiCreateDiscardableBitmap(
HDC hDC,
@ -1546,7 +1502,11 @@ BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)
if (Bitmap->SurfObj.lDelta >= 0)
bm.bmHeight = -bm.bmHeight;
res = IntCreateBitmapIndirect(&bm);
res = NtGdiCreateBitmap(bm.bmWidth,
bm.bmHeight,
bm.bmPlanes,
bm.bmBitsPixel,
bm.bmBits);
if(res)
{
PBYTE buf;

View file

@ -21,7 +21,6 @@ NtGdiCombineTransform 3
NtGdiCopyEnhMetaFile 2
NtGdiCopyMetaFile 2
NtGdiCreateBitmap 5
NtGdiCreateBitmapIndirect 1
NtGdiCreateColorSpace 1
NtGdiCreateCompatibleBitmap 3
NtGdiCreateCompatibleDC 1