mirror of
https://github.com/reactos/reactos.git
synced 2024-08-12 14:16:30 +00:00
[WIN32K]
- Work only with BITMAPINFO in GreGetDIBItsInternal and convert the structure back to BITMAPCOREINFO if needed. - Set the rgbReserved member to 0 when getting palette of a DIB section svn path=/trunk/; revision=57691
This commit is contained in:
parent
20ec872b2f
commit
5ad72c9145
|
@ -7,8 +7,11 @@ int FASTCALL DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
|
||||||
INT APIENTRY DIB_GetDIBImageBytes (INT width, INT height, INT depth);
|
INT APIENTRY DIB_GetDIBImageBytes (INT width, INT height, INT depth);
|
||||||
HPALETTE FASTCALL DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi);
|
HPALETTE FASTCALL DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi);
|
||||||
HPALETTE FASTCALL BuildDIBPalette (CONST BITMAPINFO *bmi);
|
HPALETTE FASTCALL BuildDIBPalette (CONST BITMAPINFO *bmi);
|
||||||
|
|
||||||
|
/* Those functions permit to tranparently work with a BITMAPCOREINFO structure */
|
||||||
BITMAPINFO* FASTCALL DIB_ConvertBitmapInfo(CONST BITMAPINFO* bmi, DWORD Usage);
|
BITMAPINFO* FASTCALL DIB_ConvertBitmapInfo(CONST BITMAPINFO* bmi, DWORD Usage);
|
||||||
VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig);
|
/* Pass Usage = -1 if you don't want to convert the BITMAPINFO back to BITMAPCOREINFO */
|
||||||
|
VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig, DWORD Usage);
|
||||||
|
|
||||||
INT
|
INT
|
||||||
APIENTRY
|
APIENTRY
|
||||||
|
|
|
@ -584,7 +584,6 @@ GreGetDIBitsInternal(
|
||||||
DWORD compr, size ;
|
DWORD compr, size ;
|
||||||
USHORT i;
|
USHORT i;
|
||||||
int bitmap_type;
|
int bitmap_type;
|
||||||
RGBTRIPLE* rgbTriples;
|
|
||||||
RGBQUAD* rgbQuads;
|
RGBQUAD* rgbQuads;
|
||||||
VOID* colorPtr;
|
VOID* colorPtr;
|
||||||
|
|
||||||
|
@ -594,7 +593,6 @@ GreGetDIBitsInternal(
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
colorPtr = (LPBYTE)Info + Info->bmiHeader.biSize;
|
colorPtr = (LPBYTE)Info + Info->bmiHeader.biSize;
|
||||||
rgbTriples = colorPtr;
|
|
||||||
rgbQuads = colorPtr;
|
rgbQuads = colorPtr;
|
||||||
|
|
||||||
bitmap_type = DIB_GetBitmapInfo(&Info->bmiHeader,
|
bitmap_type = DIB_GetBitmapInfo(&Info->bmiHeader,
|
||||||
|
@ -643,15 +641,6 @@ GreGetDIBitsInternal(
|
||||||
switch(bpp)
|
switch(bpp)
|
||||||
{
|
{
|
||||||
case 0: /* Only info */
|
case 0: /* Only info */
|
||||||
if(pbmci)
|
|
||||||
{
|
|
||||||
pbmci->bmciHeader.bcWidth = (WORD)psurf->SurfObj.sizlBitmap.cx;
|
|
||||||
pbmci->bmciHeader.bcHeight = (WORD)((psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ?
|
|
||||||
-psurf->SurfObj.sizlBitmap.cy :
|
|
||||||
psurf->SurfObj.sizlBitmap.cy);
|
|
||||||
pbmci->bmciHeader.bcPlanes = 1;
|
|
||||||
pbmci->bmciHeader.bcBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
|
|
||||||
}
|
|
||||||
Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx;
|
Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx;
|
||||||
Info->bmiHeader.biHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ?
|
Info->bmiHeader.biHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ?
|
||||||
-psurf->SurfObj.sizlBitmap.cy :
|
-psurf->SurfObj.sizlBitmap.cy :
|
||||||
|
@ -702,40 +691,27 @@ GreGetDIBitsInternal(
|
||||||
if(Usage == DIB_RGB_COLORS)
|
if(Usage == DIB_RGB_COLORS)
|
||||||
{
|
{
|
||||||
ULONG colors = min(psurf->ppal->NumColors, 256);
|
ULONG colors = min(psurf->ppal->NumColors, 256);
|
||||||
|
|
||||||
if(pbmci)
|
|
||||||
{
|
|
||||||
for(i = 0; i < colors; i++)
|
|
||||||
{
|
|
||||||
rgbTriples[i].rgbtRed = psurf->ppal->IndexedColors[i].peRed;
|
|
||||||
rgbTriples[i].rgbtGreen = psurf->ppal->IndexedColors[i].peGreen;
|
|
||||||
rgbTriples[i].rgbtBlue = psurf->ppal->IndexedColors[i].peBlue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(colors != 256) Info->bmiHeader.biClrUsed = colors;
|
if(colors != 256) Info->bmiHeader.biClrUsed = colors;
|
||||||
for(i = 0; i < colors; i++)
|
for(i = 0; i < colors; i++)
|
||||||
{
|
{
|
||||||
rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed;
|
rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed;
|
||||||
rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen;
|
rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen;
|
||||||
rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue;
|
rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue;
|
||||||
|
rgbQuads[i].rgbReserved = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(i = 0; i < 256; i++)
|
for(i = 0; i < 256; i++)
|
||||||
{
|
|
||||||
if(pbmci) ((WORD*)rgbTriples)[i] = i;
|
|
||||||
((WORD*)rgbQuads)[i] = i;
|
((WORD*)rgbQuads)[i] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(Usage == DIB_PAL_COLORS)
|
if(Usage == DIB_PAL_COLORS)
|
||||||
{
|
{
|
||||||
for(i = 0; i < 256; i++)
|
for(i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
if(pbmci) ((WORD*)rgbTriples)[i] = i;
|
|
||||||
((WORD*)rgbQuads)[i] = i;
|
((WORD*)rgbQuads)[i] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,13 +728,6 @@ GreGetDIBitsInternal(
|
||||||
}
|
}
|
||||||
for (i = 0; i < pDcPal->NumColors; i++)
|
for (i = 0; i < pDcPal->NumColors; i++)
|
||||||
{
|
{
|
||||||
if (pbmci)
|
|
||||||
{
|
|
||||||
rgbTriples[i].rgbtRed = pDcPal->IndexedColors[i].peRed;
|
|
||||||
rgbTriples[i].rgbtGreen = pDcPal->IndexedColors[i].peGreen;
|
|
||||||
rgbTriples[i].rgbtBlue = pDcPal->IndexedColors[i].peBlue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rgbQuads[i].rgbRed = pDcPal->IndexedColors[i].peRed;
|
rgbQuads[i].rgbRed = pDcPal->IndexedColors[i].peRed;
|
||||||
rgbQuads[i].rgbGreen = pDcPal->IndexedColors[i].peGreen;
|
rgbQuads[i].rgbGreen = pDcPal->IndexedColors[i].peGreen;
|
||||||
rgbQuads[i].rgbBlue = pDcPal->IndexedColors[i].peBlue;
|
rgbQuads[i].rgbBlue = pDcPal->IndexedColors[i].peBlue;
|
||||||
|
@ -771,55 +740,20 @@ GreGetDIBitsInternal(
|
||||||
switch (bpp)
|
switch (bpp)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
if (pbmci)
|
rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = rgbQuads[0].rgbBlue = 0;
|
||||||
{
|
|
||||||
rgbTriples[0].rgbtRed = rgbTriples[0].rgbtGreen =
|
|
||||||
rgbTriples[0].rgbtBlue = 0;
|
|
||||||
rgbTriples[1].rgbtRed = rgbTriples[1].rgbtGreen =
|
|
||||||
rgbTriples[1].rgbtBlue = 0xff;
|
|
||||||
}
|
|
||||||
rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen =
|
|
||||||
rgbQuads[0].rgbBlue = 0;
|
|
||||||
rgbQuads[0].rgbReserved = 0;
|
rgbQuads[0].rgbReserved = 0;
|
||||||
rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen =
|
rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = rgbQuads[1].rgbBlue = 0xff;
|
||||||
rgbQuads[1].rgbBlue = 0xff;
|
|
||||||
rgbQuads[1].rgbReserved = 0;
|
rgbQuads[1].rgbReserved = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
if (pbmci)
|
|
||||||
RtlCopyMemory(rgbTriples, EGAColorsTriples, sizeof(EGAColorsTriples));
|
|
||||||
RtlCopyMemory(rgbQuads, EGAColorsQuads, sizeof(EGAColorsQuads));
|
RtlCopyMemory(rgbQuads, EGAColorsQuads, sizeof(EGAColorsQuads));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
INT r, g, b;
|
INT r, g, b;
|
||||||
RGBQUAD *color;
|
RGBQUAD *color;
|
||||||
if (pbmci)
|
|
||||||
{
|
|
||||||
RGBTRIPLE *colorTriple;
|
|
||||||
|
|
||||||
RtlCopyMemory(rgbTriples, DefLogPaletteTriples,
|
|
||||||
10 * sizeof(RGBTRIPLE));
|
|
||||||
RtlCopyMemory(rgbTriples + 246, DefLogPaletteTriples + 10,
|
|
||||||
10 * sizeof(RGBTRIPLE));
|
|
||||||
colorTriple = rgbTriples + 10;
|
|
||||||
for(r = 0; r <= 5; r++) /* FIXME */
|
|
||||||
{
|
|
||||||
for(g = 0; g <= 5; g++)
|
|
||||||
{
|
|
||||||
for(b = 0; b <= 5; b++)
|
|
||||||
{
|
|
||||||
colorTriple->rgbtRed = (r * 0xff) / 5;
|
|
||||||
colorTriple->rgbtGreen = (g * 0xff) / 5;
|
|
||||||
colorTriple->rgbtBlue = (b * 0xff) / 5;
|
|
||||||
colorTriple++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memcpy(rgbQuads, DefLogPaletteQuads,
|
memcpy(rgbQuads, DefLogPaletteQuads,
|
||||||
10 * sizeof(RGBQUAD));
|
10 * sizeof(RGBQUAD));
|
||||||
memcpy(rgbQuads + 246, DefLogPaletteQuads + 10,
|
memcpy(rgbQuads + 246, DefLogPaletteQuads + 10,
|
||||||
|
@ -934,10 +868,7 @@ GreGetDIBitsInternal(
|
||||||
|
|
||||||
psurfDest = SURFACE_ShareLockSurface(hBmpDest);
|
psurfDest = SURFACE_ShareLockSurface(hBmpDest);
|
||||||
|
|
||||||
rcDest.left = 0;
|
RECTL_vSetRect(&rcDest, 0, 0, ScanLines, psurf->SurfObj.sizlBitmap.cx);
|
||||||
rcDest.top = 0;
|
|
||||||
rcDest.bottom = ScanLines;
|
|
||||||
rcDest.right = psurf->SurfObj.sizlBitmap.cx;
|
|
||||||
|
|
||||||
srcPoint.x = 0;
|
srcPoint.x = 0;
|
||||||
|
|
||||||
|
@ -987,7 +918,7 @@ done:
|
||||||
|
|
||||||
if(pDC) DC_UnlockDc(pDC);
|
if(pDC) DC_UnlockDc(pDC);
|
||||||
if(psurf) SURFACE_ShareUnlockSurface(psurf);
|
if(psurf) SURFACE_ShareUnlockSurface(psurf);
|
||||||
if(pbmci) DIB_FreeConvertedBitmapInfo(Info, (BITMAPINFO*)pbmci);
|
if(pbmci) DIB_FreeConvertedBitmapInfo(Info, (BITMAPINFO*)pbmci, Usage);
|
||||||
|
|
||||||
return ScanLines;
|
return ScanLines;
|
||||||
}
|
}
|
||||||
|
@ -1926,9 +1857,50 @@ DIB_ConvertBitmapInfo (CONST BITMAPINFO* pbmi, DWORD Usage)
|
||||||
/* Frees a BITMAPINFO created with DIB_ConvertBitmapInfo */
|
/* Frees a BITMAPINFO created with DIB_ConvertBitmapInfo */
|
||||||
VOID
|
VOID
|
||||||
FASTCALL
|
FASTCALL
|
||||||
DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig)
|
DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig, DWORD usage)
|
||||||
{
|
{
|
||||||
if(converted != orig)
|
BITMAPCOREINFO* pbmci;
|
||||||
|
if(converted == orig)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(usage == -1)
|
||||||
|
{
|
||||||
|
/* Caller don't want any conversion */
|
||||||
|
ExFreePoolWithTag(converted, TAG_DIB);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform inverse conversion */
|
||||||
|
pbmci = (BITMAPCOREINFO*)orig;
|
||||||
|
|
||||||
|
ASSERT(pbmci->bmciHeader.bcSize == sizeof(BITMAPCOREHEADER));
|
||||||
|
pbmci->bmciHeader.bcBitCount = converted->bmiHeader.biBitCount;
|
||||||
|
pbmci->bmciHeader.bcWidth = converted->bmiHeader.biWidth;
|
||||||
|
pbmci->bmciHeader.bcHeight = converted->bmiHeader.biHeight;
|
||||||
|
pbmci->bmciHeader.bcPlanes = converted->bmiHeader.biPlanes;
|
||||||
|
|
||||||
|
if(pbmci->bmciHeader.bcBitCount <= 8)
|
||||||
|
{
|
||||||
|
UINT numColors = converted->bmiHeader.biClrUsed;
|
||||||
|
if(!numColors) numColors = 1 << pbmci->bmciHeader.bcBitCount;
|
||||||
|
if(usage == DIB_PAL_COLORS)
|
||||||
|
{
|
||||||
|
RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(WORD));
|
||||||
|
RtlCopyMemory(pbmci->bmciColors, converted->bmiColors, numColors * sizeof(WORD));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UINT i;
|
||||||
|
RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(RGBTRIPLE));
|
||||||
|
for(i=0; i<numColors; i++)
|
||||||
|
{
|
||||||
|
pbmci->bmciColors[i].rgbtRed = converted->bmiColors[i].rgbRed;
|
||||||
|
pbmci->bmciColors[i].rgbtGreen = converted->bmiColors[i].rgbGreen;
|
||||||
|
pbmci->bmciColors[i].rgbtBlue = converted->bmiColors[i].rgbBlue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Now free it, it's not needed anymore */
|
||||||
ExFreePoolWithTag(converted, TAG_DIB);
|
ExFreePoolWithTag(converted, TAG_DIB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ cleanup:
|
||||||
UserReleaseDC(NULL, hdc, FALSE);
|
UserReleaseDC(NULL, hdc, FALSE);
|
||||||
|
|
||||||
if (pConvertedBmi)
|
if (pConvertedBmi)
|
||||||
DIB_FreeConvertedBitmapInfo(pConvertedBmi, pBmi);
|
DIB_FreeConvertedBitmapInfo(pConvertedBmi, pBmi, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID static NTAPI
|
VOID static NTAPI
|
||||||
|
|
|
@ -233,7 +233,7 @@ UserLoadImage(PCWSTR pwszName)
|
||||||
0);
|
0);
|
||||||
|
|
||||||
NtGdiDeleteObjectApp(hdc);
|
NtGdiDeleteObjectApp(hdc);
|
||||||
DIB_FreeConvertedBitmapInfo(pConvertedInfo, pbmi);
|
DIB_FreeConvertedBitmapInfo(pConvertedInfo, pbmi, -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue