* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id$ */
+
#include <w32k.h>
+#define NDEBUG
+#include <debug.h>
+
#define IN_RECT(r,x,y) \
( \
(x) >= (r).left && \
HDC hDCSrc,
INT XSrc,
INT YSrc,
- DWORD ROP)
+ DWORD ROP,
+ IN DWORD crBackColor,
+ IN FLONG fl)
{
PDC DCDest = NULL;
PDC DCSrc = NULL;
}
if (DCDest->IsIC)
{
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
DCSrc = DC_LockDc(hDCSrc);
if (NULL == DCSrc)
{
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiBitBlt\n", hDCSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
if (DCSrc->IsIC)
{
- DC_UnlockDc(hDCSrc);
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCSrc);
+ DC_UnlockDc(DCDest);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
DestRect.right = XDest+Width;
DestRect.bottom = YDest+Height;
+ IntLPtoDP(DCDest, (LPPOINT)&DestRect, 2);
+
SourcePoint.x = XSrc;
SourcePoint.y = YSrc;
-
+
BrushOrigin.x = 0;
BrushOrigin.y = 0;
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
if(BitmapDest != NULL)
{
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
}
if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
{
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
if(BitmapDest != NULL)
{
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
}
if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
{
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
}
if(BrushObj != NULL)
{
- BRUSHOBJ_UnlockBrush(DCDest->w.hBrush);
+ BRUSHOBJ_UnlockBrush(BrushObj);
}
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return FALSE;
}
/* Perform the bitblt operation */
- Status = IntEngBitBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip, XlateObj,
- &DestRect, &SourcePoint, NULL, BrushObj ? &BrushInst.BrushObject : NULL,
+ Status = IntEngBitBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj, NULL,
+ DCDest->CombinedClip, XlateObj, &DestRect,
+ &SourcePoint, NULL,
+ BrushObj ? &BrushInst.BrushObject : NULL,
&BrushOrigin, ROP3_TO_ROP4(ROP));
if (UsesSource && XlateObj != NULL)
EngDeleteXlate(XlateObj);
-
+
if(BitmapDest != NULL)
{
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
}
if (UsesSource && BitmapSrc != BitmapDest)
{
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
}
if (BrushObj != NULL)
{
- BRUSHOBJ_UnlockBrush(DCDest->w.hBrush);
+ BRUSHOBJ_UnlockBrush(BrushObj);
}
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
return Status;
}
USHORT PalDestMode, PalSrcMode;
ULONG TransparentColor = 0;
BOOL Ret = FALSE;
-
+
if(!(DCDest = DC_LockDc(hdcDst)))
{
DPRINT1("Invalid destination dc handle (0x%08x) passed to NtGdiTransparentBlt\n", hdcDst);
}
if (DCDest->IsIC)
{
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCDest);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
-
+
if((hdcDst != hdcSrc) && !(DCSrc = DC_LockDc(hdcSrc)))
{
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCDest);
DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiTransparentBlt\n", hdcSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
if (DCSrc->IsIC)
{
- DC_UnlockDc(hdcSrc);
+ DC_UnlockDc(DCSrc);
if(hdcDst != hdcSrc)
{
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCDest);
}
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
-
+
/* Offset positions */
xDst += DCDest->w.DCOrgX;
yDst += DCDest->w.DCOrgY;
xSrc += DCSrc->w.DCOrgX;
ySrc += DCSrc->w.DCOrgY;
-
+
if(DCDest->w.hPalette)
DestPalette = DCDest->w.hPalette;
-
+
if(DCSrc->w.hPalette)
SourcePalette = DCSrc->w.hPalette;
-
+
if(!(PalSourceGDI = PALETTE_LockPalette(SourcePalette)))
{
- DC_UnlockDc(hdcSrc);
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCSrc);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
if((DestPalette != SourcePalette) && !(PalDestGDI = PALETTE_LockPalette(DestPalette)))
{
- PALETTE_UnlockPalette(SourcePalette);
- DC_UnlockDc(hdcSrc);
- DC_UnlockDc(hdcDst);
+ PALETTE_UnlockPalette(PalSourceGDI);
+ DC_UnlockDc(DCSrc);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
{
PalDestMode = PalDestGDI->Mode;
PalSrcMode = PalSourceGDI->Mode;
- PALETTE_UnlockPalette(DestPalette);
+ PALETTE_UnlockPalette(PalDestGDI);
}
else
{
PalDestMode = PalSrcMode = PalSourceGDI->Mode;
}
- PALETTE_UnlockPalette(SourcePalette);
-
+ PALETTE_UnlockPalette(PalSourceGDI);
+
/* Translate Transparent (RGB) Color to the source palette */
if((XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalSrcMode, PAL_RGB, SourcePalette, NULL)))
{
TransparentColor = XLATEOBJ_iXlate(XlateObj, (ULONG)TransColor);
EngDeleteXlate(XlateObj);
}
-
+
/* Create the XLATE object to convert colors between source and destination */
XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette);
-
+
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
/* FIXME - BitmapDest can be NULL!!!! Don't assert here! */
ASSERT(BitmapDest);
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
/* FIXME - BitmapSrc can be NULL!!!! Don't assert here! */
ASSERT(BitmapSrc);
-
+
rcDest.left = xDst;
rcDest.top = yDst;
rcDest.right = rcDest.left + cxDst;
rcSrc.top = ySrc;
rcSrc.right = rcSrc.left + cxSrc;
rcSrc.bottom = rcSrc.top + cySrc;
-
+
if((cxDst != cxSrc) || (cyDst != cySrc))
{
DPRINT1("TransparentBlt() does not support stretching at the moment!\n");
goto done;
}
-
- Ret = IntEngTransparentBlt(BitmapDest, BitmapSrc, DCDest->CombinedClip, XlateObj, &rcDest, &rcSrc,
+
+ Ret = IntEngTransparentBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
+ DCDest->CombinedClip, XlateObj, &rcDest, &rcSrc,
TransparentColor, 0);
-
+
done:
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
- DC_UnlockDc(hdcSrc);
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
+ DC_UnlockDc(DCSrc);
if(hdcDst != hdcSrc)
{
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCDest);
}
if(XlateObj)
{
return Ret;
}
-HBITMAP STDCALL
-NtGdiCreateBitmap(
- INT Width,
- INT Height,
- UINT Planes,
- UINT BitsPerPel,
- CONST VOID *Bits)
+static FASTCALL HBITMAP
+IntCreateBitmapIndirect(CONST BITMAP *BM)
{
PBITMAPOBJ bmp;
HBITMAP hBitmap;
SIZEL Size;
+ UINT BitsPixel;
/* NOTE: Windows also doesn't store nr. of planes separately! */
- BitsPerPel = (BYTE)BitsPerPel * (BYTE)Planes;
+ BitsPixel = BM->bmBitsPixel * BM->bmPlanes;
/* Check parameters */
- if (!Height || !Width)
+ if (0 == BM->bmHeight || 0 == BM->bmWidth)
{
Size.cx = Size.cy = 1;
}
else
{
- Size.cx = abs(Width);
- Size.cy = abs(Height);
+ Size.cx = abs(BM->bmWidth);
+ Size.cy = abs(BM->bmHeight);
}
/* Create the bitmap object. */
- hBitmap = IntCreateBitmap(Size, BITMAPOBJ_GetWidthBytes(Width, BitsPerPel),
- BitmapFormat(BitsPerPel, BI_RGB),
- (Height < 0 ? BMF_TOPDOWN : 0) |
- (Bits == NULL ? 0 : BMF_NOZEROINIT), NULL);
+ hBitmap = IntCreateBitmap(Size, BM->bmWidthBytes,
+ BitmapFormat(BitsPixel, BI_RGB),
+ (BM->bmHeight < 0 ? BMF_TOPDOWN : 0) |
+ (NULL == BM->bmBits ? 0 : BMF_NOZEROINIT), NULL);
if (!hBitmap)
{
DPRINT("NtGdiCreateBitmap: IntCreateBitmap returned 0\n");
}
DPRINT("NtGdiCreateBitmap:%dx%d, %d BPP colors returning %08x\n",
- Size.cx, Size.cy, BitsPerPel, hBitmap);
+ Size.cx, Size.cy, BitsPixel, hBitmap);
bmp = BITMAPOBJ_LockBitmap( hBitmap );
/* FIXME - bmp can be NULL!!!!!! */
bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
- BITMAPOBJ_UnlockBitmap( hBitmap );
+ BITMAPOBJ_UnlockBitmap( bmp );
/*
* NOTE: It's ugly practice, but we are using the object even
* to us it should be safe.
*/
- if (Bits != NULL)
+ if (NULL != BM->bmBits)
{
- NtGdiSetBitmapBits(hBitmap, bmp->SurfObj.cjBits, Bits);
+ NtGdiSetBitmapBits(hBitmap, bmp->SurfObj.cjBits, BM->bmBits);
}
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)
{
}
}
+ if (NULL != pBmp->BitsLock)
+ {
+ ExFreePoolWithTag(pBmp->BitsLock, TAG_BITMAPOBJ);
+ pBmp->BitsLock = NULL;
+ }
+
return TRUE;
}
Bmp = IntCreateCompatibleBitmap(Dc, Width, Height);
DPRINT ("\t\t%04x\n", Bmp);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(Dc);
return Bmp;
}
HBITMAP STDCALL
-NtGdiCreateBitmapIndirect(CONST BITMAP *BM)
+NtGdiCreateBitmapIndirect(CONST BITMAP *UnsafeBM)
{
- return NtGdiCreateBitmap (BM->bmWidth,
- BM->bmHeight,
- BM->bmPlanes,
- BM->bmBitsPixel,
- BM->bmBits);
+ 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
UINT FillType)
{
DPRINT1("FIXME: NtGdiExtFloodFill is UNIMPLEMENTED\n");
-
+
/* lie and say we succeded */
return TRUE;
}
*Dimension = bmp->dimension;
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bmp);
return TRUE;
}
}
if (dc->IsIC)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Result;
}
XPos += dc->w.DCOrgX;
}
EngDeleteXlate(XlateObj);
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObject);
}
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
// if Result is still CLR_INVALID, then the "quick" method above didn't work
if ( bInRect && Result == CLR_INVALID )
{
// FIXME: create a 1x1 32BPP DIB, and blit to it
- HDC hDCTmp = NtGdiCreateCompatableDC(hDC);
+ HDC hDCTmp = NtGdiCreateCompatibleDC(hDC);
if ( hDCTmp )
{
static const BITMAPINFOHEADER bih = { sizeof(BITMAPINFOHEADER), 1, 1, 1, 32, BI_RGB, 0, 0, 0, 0, 0 };
{
PBITMAPOBJ bmpobj;
- NtGdiBitBlt ( hDCTmp, 0, 0, 1, 1, hDC, XPos, YPos, SRCCOPY );
+ NtGdiBitBlt ( hDCTmp, 0, 0, 1, 1, hDC, XPos, YPos, SRCCOPY, 0, 0 );
NtGdiSelectObject ( hDCTmp, hBmpOld );
// our bitmap is no longer selected, so we can access it's stuff...
if ( bmpobj )
{
Result = *(COLORREF*)bmpobj->SurfObj.pvScan0;
- BITMAPOBJ_UnlockBitmap ( hBmpTmp );
+ BITMAPOBJ_UnlockBitmap ( bmpobj );
}
}
NtGdiDeleteObject ( hBmpTmp );
* to GDI32. I dunno. Write a test and let me know.
*/
-static inline BYTE
+static __inline BYTE
SwapROP3_SrcDst(BYTE bRop3)
{
return (bRop3 & 0x99) | ((bRop3 & 0x22) << 1) | ((bRop3 & 0x44) >> 1);
HDC hdcDest, INT nXDest, INT nYDest,
INT nWidth, INT nHeight, HDC hdcSrc,
INT nXSrc, INT nYSrc, HBITMAP hbmMask,
- INT xMask, INT yMask, DWORD dwRop)
+ INT xMask, INT yMask, DWORD dwRop,
+ IN DWORD crBackColor)
{
HBITMAP hOldMaskBitmap, hBitmap2, hOldBitmap2, hBitmap3, hOldBitmap3;
HDC hDCMask, hDC1, hDC2;
};
if (!hbmMask)
- return NtGdiBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop));
+ return NtGdiBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop), 0, 0);
/* 1. make mask bitmap's dc */
- hDCMask = NtGdiCreateCompatableDC(hdcDest);
+ hDCMask = NtGdiCreateCompatibleDC(hdcDest);
hOldMaskBitmap = (HBITMAP)NtGdiSelectObject(hDCMask, hbmMask);
/* 2. make masked Background bitmap */
/* 2.1 make bitmap */
- hDC1 = NtGdiCreateCompatableDC(hdcDest);
+ hDC1 = NtGdiCreateCompatibleDC(hdcDest);
hBitmap2 = NtGdiCreateCompatibleBitmap(hdcDest, nWidth, nHeight);
hOldBitmap2 = (HBITMAP)NtGdiSelectObject(hDC1, hBitmap2);
/* 2.2 draw dest bitmap and mask */
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY);
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, BKGND_ROP3(dwRop));
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hDCMask, xMask, yMask, DSTERASE);
+ NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY, 0, 0);
+ NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, BKGND_ROP3(dwRop), 0, 0);
+ NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hDCMask, xMask, yMask, DSTERASE, 0, 0);
/* 3. make masked Foreground bitmap */
/* 3.1 make bitmap */
- hDC2 = NtGdiCreateCompatableDC(hdcDest);
+ hDC2 = NtGdiCreateCompatibleDC(hdcDest);
hBitmap3 = NtGdiCreateCompatibleBitmap(hdcDest, nWidth, nHeight);
hOldBitmap3 = (HBITMAP)NtGdiSelectObject(hDC2, hBitmap3);
/* 3.2 draw src bitmap and mask */
- NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY);
- NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop));
- NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hDCMask, xMask, yMask, SRCAND);
+ NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY, 0, 0);
+ NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop), 0,0);
+ NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hDCMask, xMask, yMask, SRCAND, 0, 0);
/* 4. combine two bitmap and copy it to hdcDest */
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hDC2, 0, 0, SRCPAINT);
- NtGdiBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hDC1, 0, 0, SRCCOPY);
+ NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hDC2, 0, 0, SRCPAINT, 0, 0);
+ NtGdiBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hDC1, 0, 0, SRCCOPY, 0, 0);
/* 5. restore all object */
NtGdiSelectObject(hDCMask, hOldMaskBitmap);
return TRUE;
}
-BOOL STDCALL
+BOOL
+APIENTRY
NtGdiPlgBlt(
- HDC hDCDest,
- CONST POINT *Point,
- HDC hDCSrc,
- INT XSrc,
- INT YSrc,
- INT Width,
- INT Height,
- HBITMAP hMaskBitmap,
- INT xMask,
- INT yMask)
+ IN HDC hdcTrg,
+ IN LPPOINT pptlTrg,
+ IN HDC hdcSrc,
+ IN INT xSrc,
+ IN INT ySrc,
+ IN INT cxSrc,
+ IN INT cySrc,
+ IN HBITMAP hbmMask,
+ IN INT xMask,
+ IN INT yMask,
+ IN DWORD crBackColor)
{
UNIMPLEMENTED;
return FALSE;
NtGdiSetBitmapBits(
HBITMAP hBitmap,
DWORD Bytes,
- CONST VOID *Bits)
+ IN PBYTE Bits)
{
LONG height, ret;
PBITMAPOBJ bmp;
ret = Bytes;
}
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bmp);
return ret;
}
bmp->dimension.cx = Width;
bmp->dimension.cy = Height;
- BITMAPOBJ_UnlockBitmap (hBitmap);
+ BITMAPOBJ_UnlockBitmap (bmp);
return TRUE;
}
INT Y,
COLORREF Color)
{
- COLORREF cr = NtGdiGetPixel(hDC,X,Y);
- if(cr != CLR_INVALID && NtGdiSetPixelV(hDC,X,Y,Color))
+ if (NtGdiSetPixelV(hDC,X,Y,Color))
{
- return(cr);
+ return NtGdiGetPixel(hDC,X,Y);
}
return ((COLORREF) -1);
}
INT Y,
COLORREF Color)
{
- HBRUSH NewBrush = NtGdiCreateSolidBrush(Color);
+ HBRUSH NewBrush = NtGdiCreateSolidBrush(Color, NULL);
HGDIOBJ OldBrush;
if (NewBrush == NULL)
INT YOriginSrc,
INT WidthSrc,
INT HeightSrc,
- DWORD ROP)
+ DWORD ROP,
+ IN DWORD dwBackColor)
{
PDC DCDest = NULL;
PDC DCSrc = NULL;
}
if (DCDest->IsIC)
{
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
DCSrc = DC_LockDc(hDCSrc);
if (NULL == DCSrc)
{
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiStretchBlt\n", hDCSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
if (DCSrc->IsIC)
{
- DC_UnlockDc(hDCSrc);
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCSrc);
+ DC_UnlockDc(DCDest);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return FALSE;
}
}
/* Perform the bitblt operation */
- Status = IntEngStretchBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip,
- XlateObj, &DestRect, &SourceRect, NULL, NULL, NULL, COLORONCOLOR);
+ Status = IntEngStretchBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
+ NULL, DCDest->CombinedClip, XlateObj,
+ &DestRect, &SourceRect, NULL, NULL, NULL,
+ COLORONCOLOR);
if (UsesSource)
EngDeleteXlate(XlateObj);
if (UsesPattern)
{
- BRUSHOBJ_UnlockBrush(DCDest->w.hBrush);
+ BRUSHOBJ_UnlockBrush(BrushObj);
}
failed:
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
{
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
}
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
+ }
+ DC_UnlockDc(DCDest);
+
+ return Status;
+}
+
+BOOL STDCALL
+NtGdiAlphaBlend(
+ HDC hDCDest,
+ LONG XOriginDest,
+ LONG YOriginDest,
+ LONG WidthDest,
+ LONG HeightDest,
+ HDC hDCSrc,
+ LONG XOriginSrc,
+ LONG YOriginSrc,
+ LONG WidthSrc,
+ LONG HeightSrc,
+ BLENDFUNCTION BlendFunc,
+ IN HANDLE hcmXform)
+{
+ PDC DCDest = NULL;
+ PDC DCSrc = NULL;
+ BITMAPOBJ *BitmapDest, *BitmapSrc;
+ RECTL DestRect, SourceRect;
+ BOOL Status;
+ XLATEOBJ *XlateObj;
+ BLENDOBJ BlendObj = {BlendFunc};
+ HPALETTE SourcePalette = 0, DestPalette = 0;
+
+ DCDest = DC_LockDc(hDCDest);
+ if (NULL == DCDest)
+ {
+ DPRINT1("Invalid destination dc handle (0x%08x) passed to NtGdiAlphaBlend\n", hDCDest);
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (DCDest->IsIC)
+ {
+ DC_UnlockDc(DCDest);
+ /* Yes, Windows really returns TRUE in this case */
+ return TRUE;
+ }
+
+ if (hDCSrc != hDCDest)
+ {
+ DCSrc = DC_LockDc(hDCSrc);
+ if (NULL == DCSrc)
+ {
+ DC_UnlockDc(DCDest);
+ DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiAlphaBlend\n", hDCSrc);
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (DCSrc->IsIC)
+ {
+ DC_UnlockDc(DCSrc);
+ DC_UnlockDc(DCDest);
+ /* Yes, Windows really returns TRUE in this case */
+ return TRUE;
+ }
+ }
+ else
+ {
+ DCSrc = DCDest;
+ }
+
+ /* Offset the destination and source by the origin of their DCs. */
+ XOriginDest += DCDest->w.DCOrgX;
+ YOriginDest += DCDest->w.DCOrgY;
+ XOriginSrc += DCSrc->w.DCOrgX;
+ YOriginSrc += DCSrc->w.DCOrgY;
+
+ DestRect.left = XOriginDest;
+ DestRect.top = YOriginDest;
+ DestRect.right = XOriginDest + WidthDest;
+ DestRect.bottom = YOriginDest + HeightDest;
+
+ SourceRect.left = XOriginSrc;
+ SourceRect.top = YOriginSrc;
+ SourceRect.right = XOriginSrc + WidthSrc;
+ SourceRect.bottom = YOriginSrc + HeightSrc;
+
+ /* Determine surfaces to be used in the bitblt */
+ BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
+ if (DCSrc->w.hBitmap == DCDest->w.hBitmap)
+ BitmapSrc = BitmapDest;
+ else
+ BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
+
+ /* Create the XLATEOBJ. */
+ if (DCDest->w.hPalette != 0)
+ DestPalette = DCDest->w.hPalette;
+ if (DCSrc->w.hPalette != 0)
+ SourcePalette = DCSrc->w.hPalette;
+
+ /* KB41464 details how to convert between mono and color */
+ if (DCDest->w.bitsPerPixel == 1 && DCSrc->w.bitsPerPixel == 1)
+ {
+ XlateObj = NULL;
+ }
+ else
+ {
+ if (DCDest->w.bitsPerPixel == 1)
+ {
+ XlateObj = IntEngCreateMonoXlate(0, DestPalette, SourcePalette, DCSrc->w.backgroundColor);
+ }
+ else if (DCSrc->w.bitsPerPixel == 1)
+ {
+ XlateObj = IntEngCreateSrcMonoXlate(DestPalette, DCSrc->w.backgroundColor, DCSrc->w.textColor);
+ }
+ else
+ {
+ XlateObj = IntEngCreateXlate(0, 0, DestPalette, SourcePalette);
+ }
+ if (NULL == XlateObj)
+ {
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
+ if (BitmapSrc != BitmapDest)
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
+ DC_UnlockDc(DCDest);
+ if (hDCSrc != hDCDest)
+ DC_UnlockDc(DCSrc);
+ SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
+ return FALSE;
+ }
}
- DC_UnlockDc(hDCDest);
+
+ /* Perform the alpha blend operation */
+ Status = IntEngAlphaBlend(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
+ DCDest->CombinedClip, XlateObj,
+ &DestRect, &SourceRect, &BlendObj);
+
+ if (XlateObj != NULL)
+ EngDeleteXlate(XlateObj);
+
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
+ if (BitmapSrc != BitmapDest)
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
+ DC_UnlockDc(DCDest);
+ if (hDCSrc != hDCDest)
+ DC_UnlockDc(DCSrc);
return Status;
}
if (Bitmap->SurfObj.lDelta >= 0)
bm.bmHeight = -bm.bmHeight;
- res = NtGdiCreateBitmapIndirect(&bm);
+ res = IntCreateBitmapIndirect(&bm);
if(res)
{
- char *buf;
+ PBYTE buf;
buf = ExAllocatePoolWithTag (PagedPool, bm.bmWidthBytes * abs(bm.bmHeight), TAG_BITMAP);
NtGdiGetBitmapBits (hBitmap, bm.bmWidthBytes * abs(bm.bmHeight), buf);
ExFreePool (buf);
}
- GDIOBJ_UnlockObj(hBitmap);
+ GDIOBJ_UnlockObjByPtr(Bitmap);
return res;
}
BITMAP Bitmap;
if (count > (INT) sizeof(BITMAP)) count = sizeof(BITMAP);
Bitmap.bmType = 0;
- Bitmap.bmWidth = bmp->SurfObj.sizlBitmap.cx;
- Bitmap.bmHeight = bmp->SurfObj.sizlBitmap.cy;
+ Bitmap.bmWidth = bmp->SurfObj.sizlBitmap.cx;
+ Bitmap.bmHeight = bmp->SurfObj.sizlBitmap.cy;
Bitmap.bmWidthBytes = abs(bmp->SurfObj.lDelta);
- Bitmap.bmPlanes = 1;
+ Bitmap.bmPlanes = 1;
Bitmap.bmBitsPixel = BitsPerFormat(bmp->SurfObj.iBitmapFormat);
- Bitmap.bmBits = bmp->SurfObj.pvBits;
+ Bitmap.bmBits = bmp->SurfObj.pvBits;
memcpy(buffer, &Bitmap, count);
return count;
}