Handle RLE bottom-up dibs

svn path=/trunk/; revision=9825
This commit is contained in:
Gé van Geldorp 2004-06-23 07:31:22 +00:00
parent 61d1eb4f34
commit 4d08b708f4
4 changed files with 66 additions and 63 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: surface.c,v 1.40 2004/05/30 14:01:12 weiden Exp $ /* $Id: surface.c,v 1.41 2004/06/23 07:31:22 gvg Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -317,35 +317,41 @@ EngCreateBitmap(IN SIZEL Size,
PVOID UncompressedBits; PVOID UncompressedBits;
ULONG UncompressedFormat; ULONG UncompressedFormat;
NewBitmap = (PVOID)CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ), (PVOID*)&SurfGDI, (PVOID*)&SurfObj); if (Width < 0) __asm__("int $3\n");
if( !ValidEngHandle( NewBitmap ) ) NewBitmap = (HBITMAP) CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ), (PVOID*)&SurfGDI, (PVOID*)&SurfObj);
if (! ValidEngHandle(NewBitmap))
return 0; return 0;
SurfGDI->BitsPerPixel = BitsPerFormat(Format); SurfGDI->BitsPerPixel = BitsPerFormat(Format);
if (Format == BMF_4RLE) { if (Format == BMF_4RLE)
{
SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_4BPP)); SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_4BPP));
SurfObj->cjBits = SurfObj->lDelta * Size.cy; SurfObj->cjBits = SurfObj->lDelta * Size.cy;
UncompressedFormat = BMF_4BPP; UncompressedFormat = BMF_4BPP;
UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0); UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0);
Decompress4bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, SurfObj->lDelta); Decompress4bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, SurfObj->lDelta);
} else { }
if (Format == BMF_8RLE) { else if (Format == BMF_8RLE)
{
SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_8BPP)); SurfObj->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_8BPP));
SurfObj->cjBits = SurfObj->lDelta * Size.cy; SurfObj->cjBits = SurfObj->lDelta * Size.cy;
UncompressedFormat = BMF_8BPP; UncompressedFormat = BMF_8BPP;
UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0); UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0);
Decompress8bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, SurfObj->lDelta); Decompress8bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, SurfObj->lDelta);
} else { }
else
{
SurfObj->lDelta = Width; SurfObj->lDelta = Width;
SurfObj->cjBits = SurfObj->lDelta * Size.cy; SurfObj->cjBits = Width * Size.cy;
UncompressedBits = Bits; UncompressedBits = Bits;
UncompressedFormat = Format; UncompressedFormat = Format;
} }
}
if(UncompressedBits!=NULL) if (UncompressedBits != NULL)
{ {
SurfObj->pvBits = UncompressedBits; SurfObj->pvBits = UncompressedBits;
} else }
else
{ {
if (SurfObj->cjBits == 0) if (SurfObj->cjBits == 0)
{ {
@ -353,21 +359,26 @@ EngCreateBitmap(IN SIZEL Size,
} }
else else
{ {
if(Flags & BMF_USERMEM) if (0 != (Flags & BMF_USERMEM))
{ {
SurfObj->pvBits = EngAllocUserMem(SurfObj->cjBits, 0); SurfObj->pvBits = EngAllocUserMem(SurfObj->cjBits, 0);
} else {
if(Flags & BMF_NOZEROINIT)
{
SurfObj->pvBits = EngAllocMem(0, SurfObj->cjBits, 0);
} else {
SurfObj->pvBits = EngAllocMem(FL_ZERO_MEMORY, SurfObj->cjBits, 0);
} }
else
{
SurfObj->pvBits = EngAllocMem(0 != (Flags & BMF_NOZEROINIT) ? 0 : FL_ZERO_MEMORY,
SurfObj->cjBits, 0);
} }
} }
} }
SurfObj->dhsurf = 0; // device managed surface
if (0 == (Flags & BMF_TOPDOWN))
{
SurfObj->pvBits = (PVOID) ((PCHAR) UncompressedBits + SurfObj->cjBits - SurfObj->lDelta);
SurfObj->lDelta = - SurfObj->lDelta;
}
SurfObj->dhsurf = 0; /* device managed surface */
SurfObj->hsurf = 0; SurfObj->hsurf = 0;
SurfObj->dhpdev = NULL; SurfObj->dhpdev = NULL;
SurfObj->hdev = NULL; SurfObj->hdev = NULL;
@ -380,7 +391,7 @@ EngCreateBitmap(IN SIZEL Size,
InitializeFuncs(SurfGDI, UncompressedFormat); InitializeFuncs(SurfGDI, UncompressedFormat);
// Use flags to determine bitmap type -- TOP_DOWN or whatever /* Use flags to determine bitmap type -- TOP_DOWN or whatever */
return NewBitmap; return NewBitmap;
} }

View file

@ -1,5 +1,5 @@
/* /*
* $Id: dib.c,v 1.52 2004/06/22 20:08:17 gvg Exp $ * $Id: dib.c,v 1.53 2004/06/23 07:31:22 gvg Exp $
* *
* ReactOS W32 Subsystem * ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
@ -132,8 +132,7 @@ IntSetDIBits(
//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;
const BYTE *vBits = (const BYTE*)Bits; INT DIBWidth;
INT scanDirection = 1, DIBWidth;
// Check parameters // Check parameters
if (!(bitmap = BITMAPOBJ_LockBitmap(hBitmap))) if (!(bitmap = BITMAPOBJ_LockBitmap(hBitmap)))
@ -160,18 +159,11 @@ IntSetDIBits(
// Determine width of DIB // Determine width of DIB
DIBWidth = DIB_GetDIBWidthBytes(SourceSize.cx, bmi->bmiHeader.biBitCount); 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, SourceBitmap = EngCreateBitmap(SourceSize,
DIBWidth * scanDirection, DIBWidth,
BitmapFormat(bmi->bmiHeader.biBitCount, bmi->bmiHeader.biCompression), BitmapFormat(bmi->bmiHeader.biBitCount, bmi->bmiHeader.biCompression),
0, 0 < bmi->bmiHeader.biHeight ? 0 : BMF_TOPDOWN,
(PVOID)vBits ); (PVOID) Bits);
SourceSurf = (SURFOBJ*)AccessUserObject((ULONG)SourceBitmap); SourceSurf = (SURFOBJ*)AccessUserObject((ULONG)SourceBitmap);
// Destination palette obtained from the hDC // Destination palette obtained from the hDC

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: objconv.c,v 1.18 2004/05/10 17:07:20 weiden Exp $ */ /* $Id: objconv.c,v 1.19 2004/06/23 07:31:22 gvg Exp $ */
#include <w32k.h> #include <w32k.h>
HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice) HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice)
@ -31,13 +31,13 @@ HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice)
{ {
BitmapHandle = EngCreateBitmap(Size, BitmapObj->dib->dsBm.bmWidthBytes, BitmapHandle = EngCreateBitmap(Size, BitmapObj->dib->dsBm.bmWidthBytes,
BitmapFormat(BitmapObj->dib->dsBm.bmBitsPixel, BI_RGB), BitmapFormat(BitmapObj->dib->dsBm.bmBitsPixel, BI_RGB),
0, BitmapObj->dib->dsBm.bmBits); BMF_TOPDOWN, BitmapObj->dib->dsBm.bmBits);
} }
else else
{ {
BitmapHandle = EngCreateBitmap(Size, BitmapObj->bitmap.bmWidthBytes, BitmapHandle = EngCreateBitmap(Size, BitmapObj->bitmap.bmWidthBytes,
BitmapFormat(BitmapObj->bitmap.bmBitsPixel, BI_RGB), BitmapFormat(BitmapObj->bitmap.bmBitsPixel, BI_RGB),
0, BitmapObj->bitmap.bmBits); BMF_TOPDOWN, BitmapObj->bitmap.bmBits);
} }
if (NULL != BitmapHandle && NULL != GDIDevice) if (NULL != BitmapHandle && NULL != GDIDevice)
{ {

View file

@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: text.c,v 1.97 2004/06/20 00:45:37 navaraf Exp $ */ /* $Id: text.c,v 1.98 2004/06/23 07:31:22 gvg Exp $ */
#include <w32k.h> #include <w32k.h>
#include <ft2build.h> #include <ft2build.h>
@ -1865,7 +1865,7 @@ NtGdiExtTextOut(
* limit the work of the transbitblt. * limit the work of the transbitblt.
*/ */
HSourceGlyph = EngCreateBitmap(bitSize, pitch, (glyph->bitmap.pixel_mode == ft_pixel_mode_grays) ? BMF_8BPP : BMF_1BPP, 0, glyph->bitmap.buffer); HSourceGlyph = EngCreateBitmap(bitSize, pitch, (glyph->bitmap.pixel_mode == ft_pixel_mode_grays) ? BMF_8BPP : BMF_1BPP, BMF_TOPDOWN, glyph->bitmap.buffer);
SourceGlyphSurf = (SURFOBJ*)AccessUserObject((ULONG) HSourceGlyph); SourceGlyphSurf = (SURFOBJ*)AccessUserObject((ULONG) HSourceGlyph);
/* /*