Author: gschneider
Date: Sat Mar 21 22:15:52 2009
New Revision: 40166
URL:
http://svn.reactos.org/svn/reactos?rev=40166&view=rev
Log:
- GetBitmapBits: This function should return DDB size since it's for 16 bit win only.
So calculate this size instead of supplying the DIB size
- BITMAP_GetObject: Don't always supply compression type BI_RGB, but distinguish
compression from bitmap format. A problem with BI_BITFIELDS remains, since it can't be
detected that way. Add a comment to GetDIBits too, same problem - this implicit BITFIELDS
-> RGB issue could be the reason for some (delayed?) drawing problems
- GetDIBits: The palette information should be copied in both operation modes so move it
to the beginning of the function
- Fixes ~10 gdi32 bitmap winetests (but depends on used bit depth)
Modified:
trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Sat Mar 21
22:15:52 2009
@@ -485,7 +485,7 @@
OUT OPTIONAL PBYTE pUnsafeBits)
{
PSURFACE psurf;
- LONG ret;
+ LONG bmSize, ret;
if (pUnsafeBits != NULL && Bytes == 0)
{
@@ -499,16 +499,19 @@
return 0;
}
+ bmSize = BITMAP_GetWidthBytes(psurf->SurfObj.sizlBitmap.cx,
+ BitsPerFormat(psurf->SurfObj.iBitmapFormat)) *
+ abs(psurf->SurfObj.sizlBitmap.cy);
+
/* If the bits vector is null, the function should return the read size */
if (pUnsafeBits == NULL)
{
- ret = psurf->SurfObj.cjBits;
SURFACE_UnlockSurface(psurf);
- return ret;
+ return bmSize;
}
/* Don't copy more bytes than the buffer has */
- Bytes = min(Bytes, psurf->SurfObj.cjBits);
+ Bytes = min(Bytes, bmSize);
// FIXME: use MmSecureVirtualMemory
_SEH2_TRY
@@ -852,7 +855,30 @@
pds->dsBmih.biHeight = pds->dsBm.bmHeight;
pds->dsBmih.biPlanes = pds->dsBm.bmPlanes;
pds->dsBmih.biBitCount = pds->dsBm.bmBitsPixel;
- pds->dsBmih.biCompression = 0; // FIXME!
+ switch (psurf->SurfObj.iBitmapFormat)
+ {
+ /* FIXME: What about BI_BITFIELDS? */
+ case BMF_1BPP:
+ case BMF_4BPP:
+ case BMF_8BPP:
+ case BMF_16BPP:
+ case BMF_24BPP:
+ case BMF_32BPP:
+ pds->dsBmih.biCompression = BI_RGB;
+ break;
+ case BMF_4RLE:
+ pds->dsBmih.biCompression = BI_RLE4;
+ break;
+ case BMF_8RLE:
+ pds->dsBmih.biCompression = BI_RLE8;
+ break;
+ case BMF_JPEG:
+ pds->dsBmih.biCompression = BI_JPEG;
+ break;
+ case BMF_PNG:
+ pds->dsBmih.biCompression = BI_PNG;
+ break;
+ }
pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
pds->dsBmih.biXPelsPerMeter = 0;
pds->dsBmih.biYPelsPerMeter = 0;
Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Sat Mar 21
22:15:52 2009
@@ -606,6 +606,9 @@
PBYTE ChkBits = Bits;
PVOID ColorPtr;
RGBQUAD *rgbQuads;
+ ULONG SourcePaletteType = 0;
+ ULONG DestPaletteType;
+ ULONG Index;
DPRINT("Entered NtGdiGetDIBitsInternal()\n");
@@ -655,6 +658,163 @@
ColorPtr = ((PBYTE)Info + Info->bmiHeader.biSize);
rgbQuads = (RGBQUAD *)ColorPtr;
+
+ /* Copy palette information */
+ if (Info->bmiHeader.biBitCount == BitsPerFormat(psurf->SurfObj.iBitmapFormat))
+ {
+ hDestPalette = hSourcePalette;
+ bPaletteMatch = TRUE;
+ }
+ else
+ hDestPalette = BuildDIBPalette(Info, (PINT)&DestPaletteType); //hDestPalette =
Dc->DevInfo->hpalDefault;
+
+ SourcePalette = PALETTE_LockPalette(hSourcePalette);
+ /* FIXME - SourcePalette can be NULL!!! Don't assert here! */
+ ASSERT(SourcePalette);
+ SourcePaletteType = SourcePalette->Mode;
+ PALETTE_UnlockPalette(SourcePalette);
+
+ if (bPaletteMatch)
+ {
+ DestPalette = PALETTE_LockPalette(hDestPalette);
+ /* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */
+ DPRINT("DestPalette : %p\n", DestPalette);
+ ASSERT(DestPalette);
+ DestPaletteType = DestPalette->Mode;
+ }
+ else
+ {
+ DestPalette = SourcePalette;
+ }
+
+ /* Copy palette. */
+ /* FIXME: This is largely incomplete. ATM no Core!*/
+ switch(Info->bmiHeader.biBitCount)
+ {
+ case 1:
+ case 4:
+ case 8:
+ Info->bmiHeader.biClrUsed = 0;
+ if ( psurf->hSecure &&
+ BitsPerFormat(psurf->SurfObj.iBitmapFormat) ==
Info->bmiHeader.biBitCount)
+ {
+ if (Usage == DIB_RGB_COLORS)
+ {
+ if (DestPalette->NumColors != 1 <<
Info->bmiHeader.biBitCount)
+ Info->bmiHeader.biClrUsed = DestPalette->NumColors;
+ for (Index = 0;
+ Index < (1 << Info->bmiHeader.biBitCount) &&
Index < DestPalette->NumColors;
+ Index++)
+ {
+ rgbQuads[Index].rgbRed =
DestPalette->IndexedColors[Index].peRed;
+ rgbQuads[Index].rgbGreen =
DestPalette->IndexedColors[Index].peGreen;
+ rgbQuads[Index].rgbBlue =
DestPalette->IndexedColors[Index].peBlue;
+ rgbQuads[Index].rgbReserved = 0;
+ }
+ }
+ else
+ {
+ PWORD Ptr = ColorPtr;
+ for (Index = 0;
+ Index < (1 << Info->bmiHeader.biBitCount);
+ Index++)
+ {
+ Ptr[Index] = (WORD)Index;
+ }
+ }
+ }
+ else
+ {
+ if (Usage == DIB_PAL_COLORS)
+ {
+ PWORD Ptr = ColorPtr;
+ for (Index = 0;
+ Index < (1 << Info->bmiHeader.biBitCount);
+ Index++)
+ {
+ Ptr[Index] = (WORD)Index;
+ }
+ }
+ else if (Info->bmiHeader.biBitCount > 1 && bPaletteMatch)
+ {
+ for (Index = 0;
+ Index < (1 << Info->bmiHeader.biBitCount) &&
Index < DestPalette->NumColors;
+ Index++)
+ {
+ Info->bmiColors[Index].rgbRed =
DestPalette->IndexedColors[Index].peRed;
+ Info->bmiColors[Index].rgbGreen =
DestPalette->IndexedColors[Index].peGreen;
+ Info->bmiColors[Index].rgbBlue =
DestPalette->IndexedColors[Index].peBlue;
+ Info->bmiColors[Index].rgbReserved = 0;
+ }
+ }
+ else
+ {
+ switch(Info->bmiHeader.biBitCount)
+ {
+ case 1:
+ rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = rgbQuads[0].rgbBlue =
0;
+ rgbQuads[0].rgbReserved = 0;
+ rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = rgbQuads[1].rgbBlue =
0xff;
+ rgbQuads[1].rgbReserved = 0;
+ break;
+ case 4:
+ RtlCopyMemory(ColorPtr, EGAColorsQuads, sizeof(EGAColorsQuads));
+ break;
+ case 8:
+ {
+ INT r, g, b;
+ RGBQUAD *color;
+
+ RtlCopyMemory(rgbQuads, DefLogPaletteQuads, 10 * sizeof(RGBQUAD));
+ RtlCopyMemory(rgbQuads + 246, DefLogPaletteQuads + 10, 10 *
sizeof(RGBQUAD));
+ color = rgbQuads + 10;
+ for(r = 0; r <= 5; r++) /* FIXME */
+ for(g = 0; g <= 5; g++)
+ for(b = 0; b <= 5; b++)
+ {
+ color->rgbRed = (r * 0xff) / 5;
+ color->rgbGreen = (g * 0xff) / 5;
+ color->rgbBlue = (b * 0xff) / 5;
+ color->rgbReserved = 0;
+ color++;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ case 15:
+ if (Info->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ ((PDWORD)Info->bmiColors)[0] = 0x7c00;
+ ((PDWORD)Info->bmiColors)[1] = 0x03e0;
+ ((PDWORD)Info->bmiColors)[2] = 0x001f;
+ }
+ break;
+
+ case 16:
+ if (Info->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ ((PDWORD)Info->bmiColors)[0] = 0xf800;
+ ((PDWORD)Info->bmiColors)[1] = 0x07e0;
+ ((PDWORD)Info->bmiColors)[2] = 0x001f;
+ }
+ break;
+
+ case 24:
+ case 32:
+ if (Info->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ ((PDWORD)Info->bmiColors)[0] = 0xff0000;
+ ((PDWORD)Info->bmiColors)[1] = 0x00ff00;
+ ((PDWORD)Info->bmiColors)[2] = 0x0000ff;
+ }
+ break;
+ }
+
+ if (bPaletteMatch)
+ PALETTE_UnlockPalette(DestPalette);
/* fill out the BITMAPINFO struct */
if (!ChkBits)
@@ -678,6 +838,7 @@
Info->bmiHeader.biBitCount =
BitsPerFormat(psurf->SurfObj.iBitmapFormat);
switch (psurf->SurfObj.iBitmapFormat)
{
+ /* FIXME: What about BI_BITFIELDS? */
case BMF_1BPP:
case BMF_4BPP:
case BMF_8BPP:
@@ -715,166 +876,8 @@
else
{
SIZEL DestSize;
- ULONG SourcePaletteType = 0;
- ULONG DestPaletteType;
POINTL SourcePoint;
- ULONG Index;
-
- if (Info->bmiHeader.biBitCount ==
BitsPerFormat(psurf->SurfObj.iBitmapFormat))
- {
- hDestPalette = hSourcePalette;
- bPaletteMatch = TRUE;
- }
- else
- hDestPalette = BuildDIBPalette(Info, (PINT)&DestPaletteType);
//hDestPalette = Dc->DevInfo->hpalDefault;
-
- SourcePalette = PALETTE_LockPalette(hSourcePalette);
- /* FIXME - SourcePalette can be NULL!!! Don't assert here! */
- ASSERT(SourcePalette);
- SourcePaletteType = SourcePalette->Mode;
- PALETTE_UnlockPalette(SourcePalette);
-
- if (bPaletteMatch)
- {
- DestPalette = PALETTE_LockPalette(hDestPalette);
- /* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */
- DPRINT("DestPalette : %p\n", DestPalette);
- ASSERT(DestPalette);
- DestPaletteType = DestPalette->Mode;
- }
- else
- {
- DestPalette = SourcePalette;
- }
-
- /* Copy palette. */
- /* FIXME: This is largely incomplete. ATM no Core!*/
- switch(Info->bmiHeader.biBitCount)
- {
- case 1:
- case 4:
- case 8:
- Info->bmiHeader.biClrUsed = 0;
- if ( psurf->hSecure &&
- BitsPerFormat(psurf->SurfObj.iBitmapFormat) ==
Info->bmiHeader.biBitCount)
- {
- if (Usage == DIB_RGB_COLORS)
- {
- if (DestPalette->NumColors != 1 <<
Info->bmiHeader.biBitCount)
- Info->bmiHeader.biClrUsed = DestPalette->NumColors;
- for (Index = 0;
- Index < (1 << Info->bmiHeader.biBitCount) &&
Index < DestPalette->NumColors;
- Index++)
- {
- rgbQuads[Index].rgbRed =
DestPalette->IndexedColors[Index].peRed;
- rgbQuads[Index].rgbGreen =
DestPalette->IndexedColors[Index].peGreen;
- rgbQuads[Index].rgbBlue =
DestPalette->IndexedColors[Index].peBlue;
- rgbQuads[Index].rgbReserved = 0;
- }
- }
- else
- {
- PWORD Ptr = ColorPtr;
- for (Index = 0;
- Index < (1 << Info->bmiHeader.biBitCount);
- Index++)
- {
- Ptr[Index] = (WORD)Index;
- }
- }
- }
- else
- {
- if (Usage == DIB_PAL_COLORS)
- {
- PWORD Ptr = ColorPtr;
- for (Index = 0;
- Index < (1 << Info->bmiHeader.biBitCount);
- Index++)
- {
- Ptr[Index] = (WORD)Index;
- }
- }
- else if (Info->bmiHeader.biBitCount > 1 && bPaletteMatch)
- {
- for (Index = 0;
- Index < (1 << Info->bmiHeader.biBitCount) &&
Index < DestPalette->NumColors;
- Index++)
- {
- Info->bmiColors[Index].rgbRed =
DestPalette->IndexedColors[Index].peRed;
- Info->bmiColors[Index].rgbGreen =
DestPalette->IndexedColors[Index].peGreen;
- Info->bmiColors[Index].rgbBlue =
DestPalette->IndexedColors[Index].peBlue;
- Info->bmiColors[Index].rgbReserved = 0;
- }
- }
- else
- {
- switch(Info->bmiHeader.biBitCount)
- {
- case 1:
- rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = rgbQuads[0].rgbBlue
= 0;
- rgbQuads[0].rgbReserved = 0;
- rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = rgbQuads[1].rgbBlue
= 0xff;
- rgbQuads[1].rgbReserved = 0;
- break;
- case 4:
- RtlCopyMemory(ColorPtr, EGAColorsQuads,
sizeof(EGAColorsQuads));
- break;
- case 8:
- {
- INT r, g, b;
- RGBQUAD *color;
-
- RtlCopyMemory(rgbQuads, DefLogPaletteQuads, 10 *
sizeof(RGBQUAD));
- RtlCopyMemory(rgbQuads + 246, DefLogPaletteQuads + 10, 10 *
sizeof(RGBQUAD));
- color = rgbQuads + 10;
- for(r = 0; r <= 5; r++) /* FIXME */
- for(g = 0; g <= 5; g++)
- for(b = 0; b <= 5; b++)
- {
- color->rgbRed = (r * 0xff) / 5;
- color->rgbGreen = (g * 0xff) / 5;
- color->rgbBlue = (b * 0xff) / 5;
- color->rgbReserved = 0;
- color++;
- }
- }
- break;
- }
- }
- }
-
- case 15:
- if (Info->bmiHeader.biCompression == BI_BITFIELDS)
- {
- ((PDWORD)Info->bmiColors)[0] = 0x7c00;
- ((PDWORD)Info->bmiColors)[1] = 0x03e0;
- ((PDWORD)Info->bmiColors)[2] = 0x001f;
- }
- break;
-
- case 16:
- if (Info->bmiHeader.biCompression == BI_BITFIELDS)
- {
- ((PDWORD)Info->bmiColors)[0] = 0xf800;
- ((PDWORD)Info->bmiColors)[1] = 0x07e0;
- ((PDWORD)Info->bmiColors)[2] = 0x001f;
- }
- break;
-
- case 24:
- case 32:
- if (Info->bmiHeader.biCompression == BI_BITFIELDS)
- {
- ((PDWORD)Info->bmiColors)[0] = 0xff0000;
- ((PDWORD)Info->bmiColors)[1] = 0x00ff00;
- ((PDWORD)Info->bmiColors)[2] = 0x0000ff;
- }
- break;
- }
-
- if (bPaletteMatch)
- PALETTE_UnlockPalette(DestPalette);
+
//
// If we have a good dib pointer, why not just copy bits from there w/o XLATE'ing
them.
//