CONST BITMAPINFO *bmi,
UINT ColorUse)
{
- HBITMAP SourceBitmap, hOldSrcBmp = NULL, hOldDstBmp = NULL;
- HDC hdcSrc, hdcDst;
+ HBITMAP SourceBitmap;
+ PSURFACE psurfDst, psurfSrc;
INT result = 0;
+ RECT rcDst;
+ POINTL ptSrc;
PVOID pvBits;
+ EXLATEOBJ exlo;
SourceBitmap = DIB_CreateDIBSection(DC, bmi, ColorUse, &pvBits, NULL, 0, 0);
if (0 == SourceBitmap)
bmi->bmiHeader.biHeight,
bmi->bmiHeader.biBitCount));
- hdcSrc = NtGdiCreateCompatibleDC(0);
- hdcDst = NtGdiCreateCompatibleDC(0);
+ psurfDst = SURFACE_LockSurface(hBitmap);
+ psurfSrc = SURFACE_LockSurface(SourceBitmap);
- if(!(hdcSrc && hdcDst))
+ if(!(psurfSrc && psurfDst))
{
- DPRINT1("Error, could not create memory DCs.\n");
+ DPRINT1("Error, could not lock surfaces.\n");
goto cleanup;
}
- hOldSrcBmp = NtGdiSelectBitmap(hdcSrc, SourceBitmap);
- hOldDstBmp = NtGdiSelectBitmap(hdcDst, hBitmap);
+ rcDst.top = bmi->bmiHeader.biHeight < 0 ?
+ abs(bmi->bmiHeader.biHeight) - (ScanLines + StartScan) : StartScan;
+ rcDst.left = 0;
+ rcDst.bottom = rcDst.top + ScanLines;
+ rcDst.right = psurfDst->SurfObj.sizlBitmap.cx;
- if(!(hOldSrcBmp && hOldDstBmp))
- {
- DPRINT1("Error : Could not select bitmaps into DCs\n");
- goto cleanup;
- }
+ ptSrc.x = 0;
+ ptSrc.y = 0;
- result = NtGdiBitBlt(hdcDst, 0, 0, bmi->bmiHeader.biWidth, ScanLines, hdcSrc, 0, StartScan,
- SRCCOPY, 0, 0);
+ EXLATEOBJ_vInitialize(&exlo, psurfSrc->ppal, psurfDst->ppal, 0, 0, 0);
+ result = IntEngCopyBits(&psurfDst->SurfObj,
+ &psurfSrc->SurfObj,
+ NULL,
+ &exlo.xlo,
+ &rcDst,
+ &ptSrc);
if(result)
result = ScanLines;
+ EXLATEOBJ_vCleanup(&exlo);
+
cleanup:
- if(hdcSrc)
+ if(psurfSrc)
{
- if(hOldSrcBmp) NtGdiSelectBitmap(hdcSrc, hOldSrcBmp);
- NtGdiDeleteObjectApp(hdcSrc);
+ SURFACE_UnlockSurface(psurfSrc);
}
- if(hdcDst)
+ if(psurfDst)
{
- if(hOldDstBmp) NtGdiSelectBitmap(hdcDst, hOldDstBmp);
- NtGdiDeleteObjectApp(hdcDst);
+ SURFACE_UnlockSurface(psurfDst);
}
GreDeleteObject(SourceBitmap);
Info->bmiHeader.biYPelsPerMeter = 0;
Info->bmiHeader.biClrUsed = 0;
Info->bmiHeader.biClrImportant = 0;
- ScanLines = psurf->SurfObj.sizlBitmap.cy;
- /* Get Complete info now */
+ ScanLines = abs(Info->bmiHeader.biHeight);
goto done;
case 1:
}
}
if(colors != 1 << bpp) Info->bmiHeader.biClrUsed = colors;
- RtlCopyMemory(rgbQuads, psurf->ppal->IndexedColors, colors * sizeof(RGBQUAD));
+ for(i=0; i < colors; i++)
+ {
+ rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed;
+ rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen;
+ rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue;
+ }
}
else
{
{
/* Create a DIBSECTION, blt it, profit */
PVOID pDIBits ;
- HBITMAP hBmpDest, hOldDest = NULL, hOldSrc = NULL;
- HDC hdcDest = NULL, hdcSrc;
+ HBITMAP hBmpDest;
+ PSURFACE psurfDest;
+ EXLATEOBJ exlo;
+ RECT rcDest;
+ POINTL srcPoint;
BOOL ret ;
if (StartScan > psurf->SurfObj.sizlBitmap.cy)
ScanLines = min(ScanLines, psurf->SurfObj.sizlBitmap.cy - StartScan);
}
+ /* Fixup values */
+ Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx;
+ Info->bmiHeader.biHeight = height < 0 ?
+ -ScanLines : ScanLines;
+ /* Create the DIB */
hBmpDest = DIB_CreateDIBSection(pDC, Info, Usage, &pDIBits, NULL, 0, 0);
+ /* Restore them */
+ Info->bmiHeader.biWidth = width;
+ Info->bmiHeader.biHeight = height;
if(!hBmpDest)
{
goto done ;
}
- if(psurf->hdc)
- hdcSrc = psurf->hdc;
- else
- {
- hdcSrc = NtGdiCreateCompatibleDC(0);
- if(!hdcSrc)
- {
- DPRINT1("Error: could not create HDC!\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
- hOldSrc = NtGdiSelectBitmap(hdcSrc, hBitmap);
- if(!hOldSrc)
- {
- DPRINT1("Error : Could not Select bitmap\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
- }
+ psurfDest = SURFACE_LockSurface(hBmpDest);
- hdcDest = NtGdiCreateCompatibleDC(0);
- if(!hdcDest)
- {
- DPRINT1("Error: could not create HDC!\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
- hOldDest = NtGdiSelectBitmap(hdcDest, hBmpDest);
- if(!hOldDest)
- {
- DPRINT1("Error : Could not Select bitmap\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
+ rcDest.left = 0;
+ rcDest.top = 0;
+ rcDest.bottom = ScanLines;
+ rcDest.right = psurf->SurfObj.sizlBitmap.cx;
+
+ srcPoint.x = 0;
+ srcPoint.y = height < 0 ?
+ psurf->SurfObj.sizlBitmap.cy - (StartScan + ScanLines) : StartScan;
- ret = GreStretchBltMask(hdcDest,
- 0,
- 0,
- width,
- height,
- hdcSrc,
- 0,
- StartScan,
- psurf->SurfObj.sizlBitmap.cx,
- ScanLines,
- SRCCOPY,
- 0,
- NULL,
- 0,
- 0);
+ EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0, 0, 0);
+
+ ret = IntEngCopyBits(&psurfDest->SurfObj,
+ &psurf->SurfObj,
+ NULL,
+ &exlo.xlo,
+ &rcDest,
+ &srcPoint);
if(!ret)
ScanLines = 0;
}
}
- cleanup_blt:
- if(hdcSrc && (hdcSrc != psurf->hdc))
- {
- if(hOldSrc) NtGdiSelectBitmap(hdcSrc, hOldSrc);
- NtGdiDeleteObjectApp(hdcSrc);
- }
- if(hdcSrc)
- {
- if(hOldDest) NtGdiSelectBitmap(hdcDest, hOldDest);
- NtGdiDeleteObjectApp(hdcDest);
- }
GreDeleteObject(hBmpDest);
+ EXLATEOBJ_vCleanup(&exlo);
}
+ else ScanLines = abs(height);
done:
return 0;
}
+ /* Set bits */
_SEH2_TRY
{
ProbeForRead(Bits, cjMaxBits, 1);