Fixes for DIBs to show with correct vertical orientation

svn path=/trunk/; revision=3514
This commit is contained in:
Jason Filby 2002-09-17 23:20:44 +00:00
parent 319a04a8a0
commit 8c69edcca7
6 changed files with 40 additions and 18 deletions

View file

@ -14,7 +14,7 @@ PFN_DIB_VLine DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
BOOLEAN DIB_To_1BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN DIB_To_1BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI, SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint, PRECTL DestRect, POINTL *SourcePoint,
ULONG Delta, XLATEOBJ *ColorTranslation); LONG Delta, XLATEOBJ *ColorTranslation);
PFN_DIB_PutPixel DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c); PFN_DIB_PutPixel DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
PFN_DIB_GetPixel DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y); PFN_DIB_GetPixel DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
@ -23,7 +23,7 @@ PFN_DIB_VLine DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI, SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint, PRECTL DestRect, POINTL *SourcePoint,
ULONG Delta, XLATEOBJ *ColorTranslation); LONG Delta, XLATEOBJ *ColorTranslation);
PFN_DIB_PutPixel DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c); PFN_DIB_PutPixel DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c);
PFN_DIB_GetPixel DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y); PFN_DIB_GetPixel DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y);
@ -32,4 +32,4 @@ PFN_DIB_VLine DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG
BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI, SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint, PRECTL DestRect, POINTL *SourcePoint,
ULONG Delta, XLATEOBJ *ColorTranslation); LONG Delta, XLATEOBJ *ColorTranslation);

View file

@ -53,9 +53,9 @@ PFN_DIB_VLine DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
BOOLEAN DIB_To_1BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN DIB_To_1BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI, SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint, PRECTL DestRect, POINTL *SourcePoint,
ULONG Delta, XLATEOBJ *ColorTranslation) LONG Delta, XLATEOBJ *ColorTranslation)
{ {
ULONG i, j, sx, sy = SourcePoint->y; LONG i, j, sx, sy = SourcePoint->y;
switch(SourceGDI->BitsPerPixel) switch(SourceGDI->BitsPerPixel)
{ {

View file

@ -41,7 +41,7 @@ PFN_DIB_VLine DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG
{ {
PBYTE byteaddr = SurfObj->pvBits + y1 * SurfObj->lDelta; PBYTE byteaddr = SurfObj->pvBits + y1 * SurfObj->lDelta;
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x; PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
ULONG lDelta = SurfObj->lDelta; LONG lDelta = SurfObj->lDelta;
byteaddr = (PBYTE)addr; byteaddr = (PBYTE)addr;
while(y1++ <= y2) { while(y1++ <= y2) {
@ -86,9 +86,9 @@ VOID DIB_24BPP_BltTo_24BPP(PSURFOBJ dstpsd, LONG dstx, LONG dsty, LONG w, LONG h
BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI, SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint, PRECTL DestRect, POINTL *SourcePoint,
ULONG Delta, XLATEOBJ *ColorTranslation) LONG Delta, XLATEOBJ *ColorTranslation)
{ {
ULONG i, j, sx, sy, xColor, f1; LONG i, j, sx, sy, xColor, f1;
PBYTE DestBits, SourceBits_24BPP, DestLine, SourceLine_24BPP; PBYTE DestBits, SourceBits_24BPP, DestLine, SourceLine_24BPP;
PRGBTRIPLE SPDestBits, SPSourceBits_24BPP, SPDestLine, SPSourceLine_24BPP; // specially for 24-to-24 blit PRGBTRIPLE SPDestBits, SPSourceBits_24BPP, SPDestLine, SPSourceLine_24BPP; // specially for 24-to-24 blit
PBYTE SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP; PBYTE SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP;

View file

@ -53,9 +53,9 @@ PFN_DIB_VLine DIB_4BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c
BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI, SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint, PRECTL DestRect, POINTL *SourcePoint,
ULONG Delta, XLATEOBJ *ColorTranslation) LONG Delta, XLATEOBJ *ColorTranslation)
{ {
ULONG i, j, sx, sy, f1, f2, xColor; LONG i, j, sx, sy, f1, f2, xColor;
PBYTE SourceBits_24BPP, SourceLine_24BPP; PBYTE SourceBits_24BPP, SourceLine_24BPP;
PBYTE DestBits, DestLine, SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP; PBYTE DestBits, DestLine, SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP;
PWORD SourceBits_16BPP, SourceLine_16BPP; PWORD SourceBits_16BPP, SourceLine_16BPP;

View file

@ -19,9 +19,9 @@
BOOLEAN CopyBitsCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN CopyBitsCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI, SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint, PRECTL DestRect, POINTL *SourcePoint,
ULONG Delta, XLATEOBJ *ColorTranslation) LONG Delta, XLATEOBJ *ColorTranslation)
{ {
ULONG DestWidth, DestHeight, CurrentDestLine, CurrentSourceLine, CurrentDestCol, CurrentSourceCol, i, TranslationPixel; LONG DestWidth, DestHeight, CurrentDestLine, CurrentSourceLine, CurrentDestCol, CurrentSourceCol, i, TranslationPixel;
PFN_DIB_GetPixel Source_DIB_GetPixel; PFN_DIB_GetPixel Source_DIB_GetPixel;
PFN_DIB_PutPixel Dest_DIB_PutPixel; PFN_DIB_PutPixel Dest_DIB_PutPixel;

View file

@ -65,7 +65,7 @@ INT STDCALL W32kSetDIBits(HDC hDC,
DC *dc; DC *dc;
BITMAPOBJ *bitmap; BITMAPOBJ *bitmap;
HBITMAP SourceBitmap, DestBitmap; HBITMAP SourceBitmap, DestBitmap;
INT result; INT result = 0;
BOOL copyBitsResult; BOOL copyBitsResult;
PSURFOBJ DestSurf, SourceSurf; PSURFOBJ DestSurf, SourceSurf;
PSURFGDI DestGDI; PSURFGDI DestGDI;
@ -77,7 +77,8 @@ INT STDCALL W32kSetDIBits(HDC hDC,
RGBQUAD *lpRGB; RGBQUAD *lpRGB;
HPALETTE DDB_Palette, DIB_Palette; HPALETTE DDB_Palette, DIB_Palette;
ULONG DDB_Palette_Type, DIB_Palette_Type; ULONG DDB_Palette_Type, DIB_Palette_Type;
PBYTE vBits = Bits;
INT scanDirection = 1, DIBWidth;
// Check parameters // Check parameters
if (!(dc = DC_HandleToPtr(hDC))) if (!(dc = DC_HandleToPtr(hDC)))
@ -105,10 +106,23 @@ INT STDCALL W32kSetDIBits(HDC hDC,
// Create source surface // Create source surface
SourceSize.cx = bmi->bmiHeader.biWidth; SourceSize.cx = bmi->bmiHeader.biWidth;
SourceSize.cy = bmi->bmiHeader.biHeight; SourceSize.cy = abs(bmi->bmiHeader.biHeight);
SourceBitmap = EngCreateBitmap(SourceSize, DIB_GetDIBWidthBytes(SourceSize.cx, bmi->bmiHeader.biBitCount),
// Determine width of DIB
DIBWidth = DIB_GetDIBWidthBytes(SourceSize.cx, bmi->bmiHeader.biBitCount);
// Determine DIB Vertical Orientation
if(bmi->bmiHeader.biHeight > 0)
{
scanDirection = -1;
vBits += DIBWidth * bmi->bmiHeader.biHeight - DIBWidth;
}
SourceBitmap = EngCreateBitmap(SourceSize,
DIBWidth * scanDirection,
BitmapFormat(bmi->bmiHeader.biBitCount, bmi->bmiHeader.biCompression), BitmapFormat(bmi->bmiHeader.biBitCount, bmi->bmiHeader.biCompression),
0, Bits); 0,
vBits);
SourceSurf = (PSURFOBJ)AccessUserObject(SourceBitmap); SourceSurf = (PSURFOBJ)AccessUserObject(SourceBitmap);
// Destination palette obtained from the hDC // Destination palette obtained from the hDC
@ -122,9 +136,11 @@ INT STDCALL W32kSetDIBits(HDC hDC,
// Determine XLATEOBJ for color translation // Determine XLATEOBJ for color translation
XlateObj = EngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_Palette, DIB_Palette); XlateObj = EngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_Palette, DIB_Palette);
// Determine destination rectangle and source point // Zero point
ZeroPoint.x = 0; ZeroPoint.x = 0;
ZeroPoint.y = 0; ZeroPoint.y = 0;
// Determine destination rectangle
DestRect.top = 0; DestRect.top = 0;
DestRect.left = 0; DestRect.left = 0;
DestRect.right = SourceSize.cx; DestRect.right = SourceSize.cx;
@ -132,6 +148,12 @@ INT STDCALL W32kSetDIBits(HDC hDC,
copyBitsResult = EngCopyBits(DestSurf, SourceSurf, NULL, XlateObj, &DestRect, &ZeroPoint); copyBitsResult = EngCopyBits(DestSurf, SourceSurf, NULL, XlateObj, &DestRect, &ZeroPoint);
// If it succeeded, return number of scanlines copies
if(copyBitsResult == TRUE)
{
result = SourceSize.cy - 1;
}
// Clean up // Clean up
EngDeleteSurface(SourceBitmap); EngDeleteSurface(SourceBitmap);
EngDeleteSurface(DestBitmap); EngDeleteSurface(DestBitmap);