mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 14:08:22 +00:00
[COMCTL32] Saturated images: Take mask-images in account.
This fixes CORE-14209 - Some icons not drawn in IDA Free
This commit is contained in:
parent
49a797543f
commit
4093681ad0
1 changed files with 41 additions and 17 deletions
|
@ -1281,7 +1281,7 @@ ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
static BOOL alpha_blend_image( HIMAGELIST himl, HDC srce_dc, HDC dest_dc, int dest_x, int dest_y,
|
static BOOL alpha_blend_image( HIMAGELIST himl, HDC srce_dc, HDC srce_dcMask, HDC dest_dc, int dest_x, int dest_y,
|
||||||
#else
|
#else
|
||||||
static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int dest_y,
|
static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int dest_y,
|
||||||
#endif
|
#endif
|
||||||
|
@ -1316,7 +1316,7 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
|
||||||
#endif
|
#endif
|
||||||
SelectObject( hdc, bmp );
|
SelectObject( hdc, bmp );
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
if (!BitBlt( hdc, 0, 0, cx, cy, srce_dc, src_x, src_y, SRCCOPY ))
|
if (!BitBlt(hdc, 0, 0, cx, cy, srce_dc, src_x, src_y, SRCCOPY))
|
||||||
{
|
{
|
||||||
TRACE("BitBlt failed\n");
|
TRACE("BitBlt failed\n");
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1375,7 +1375,7 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
|
||||||
info->bmiColors[1].rgbGreen = 0xff;
|
info->bmiColors[1].rgbGreen = 0xff;
|
||||||
info->bmiColors[1].rgbBlue = 0xff;
|
info->bmiColors[1].rgbBlue = 0xff;
|
||||||
info->bmiColors[1].rgbReserved = 0;
|
info->bmiColors[1].rgbReserved = 0;
|
||||||
if (!(mask = CreateDIBSection( himl->hdcMask, info, DIB_RGB_COLORS, &mask_bits, 0, 0 )))
|
if (!(mask = CreateDIBSection( srce_dcMask, info, DIB_RGB_COLORS, &mask_bits, 0, 0)))
|
||||||
{
|
{
|
||||||
TRACE("CreateDIBSection failed %i\n", GetLastError());
|
TRACE("CreateDIBSection failed %i\n", GetLastError());
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1386,13 +1386,13 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
|
||||||
SelectObject(hdc, bmp);
|
SelectObject(hdc, bmp);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (!BitBlt(hdc, 0, 0, cx, cy, himl->hdcMask, src_x, src_y, SRCCOPY))
|
if (!BitBlt( hdc, 0, 0, cx, cy, srce_dcMask, src_x, src_y, SRCCOPY))
|
||||||
{
|
{
|
||||||
TRACE("BitBlt failed %i\n", GetLastError());
|
TRACE("BitBlt failed %i\n", GetLastError());
|
||||||
SelectObject(hdc, bmp);
|
SelectObject(hdc, bmp);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (SelectObject(hdc, bmp) == NULL)
|
if (SelectObject( hdc, bmp) == NULL)
|
||||||
{
|
{
|
||||||
TRACE("SelectObject failed %i\n", GetLastError());
|
TRACE("SelectObject failed %i\n", GetLastError());
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1414,11 +1414,12 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
HDC saturate_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int dest_y,
|
BOOL saturate_image(HIMAGELIST himl, HDC dest_dc, int dest_x, int dest_y,
|
||||||
int src_x, int src_y, int cx, int cy, COLORREF rgbFg)
|
int src_x, int src_y, int cx, int cy, COLORREF rgbFg,
|
||||||
|
HDC *hdcImageListDC, HDC *hdcMaskListDC)
|
||||||
{
|
{
|
||||||
HDC hdc = NULL;
|
HDC hdc = NULL, hdcMask = NULL;
|
||||||
HBITMAP bmp = 0;
|
HBITMAP bmp = 0, bmpMask = 0;
|
||||||
BITMAPINFO *info;
|
BITMAPINFO *info;
|
||||||
|
|
||||||
unsigned int *ptr;
|
unsigned int *ptr;
|
||||||
|
@ -1470,16 +1471,37 @@ HDC saturate_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int dest_y,
|
||||||
*ptr = RGBA(mixed_color, mixed_color, mixed_color, GetAValue(orig_color));
|
*ptr = RGBA(mixed_color, mixed_color, mixed_color, GetAValue(orig_color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (himl->hdcMask)
|
||||||
|
{
|
||||||
|
hdcMask = CreateCompatibleDC(NULL);
|
||||||
|
bmpMask = CreateCompatibleBitmap(hdcMask, cx, cy);
|
||||||
|
|
||||||
|
SelectObject(hdcMask, bmpMask);
|
||||||
|
|
||||||
|
if (!BitBlt(hdcMask, 0, 0, cx, cy, himl->hdcMask, src_x, src_y, SRCCOPY))
|
||||||
|
{
|
||||||
|
ERR("BitBlt failed %i\n", GetLastError());
|
||||||
|
DeleteDC(hdcMask);
|
||||||
|
hdcMask = NULL;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
TRACE("mask ok\n");
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
if (bmp)
|
if (bmp)
|
||||||
DeleteObject(bmp);
|
DeleteObject(bmp);
|
||||||
|
if (bmpMask)
|
||||||
|
DeleteObject(bmpMask);
|
||||||
|
|
||||||
if (info)
|
if (info)
|
||||||
HeapFree(GetProcessHeap(), 0, info);
|
HeapFree(GetProcessHeap(), 0, info);
|
||||||
|
|
||||||
/* return the handle to our desaturated dc, that will substitute its original counterpart in the next calls */
|
/* return the handle to our desaturated dc, that will substitute its original counterpart in the next calls */
|
||||||
return hdc;
|
*hdcMaskListDC = hdcMask;
|
||||||
|
*hdcImageListDC = hdc;
|
||||||
|
return (hdc != NULL);
|
||||||
}
|
}
|
||||||
#endif /* __REACTOS__ */
|
#endif /* __REACTOS__ */
|
||||||
|
|
||||||
|
@ -1511,7 +1533,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
|
||||||
POINT pt;
|
POINT pt;
|
||||||
BOOL has_alpha;
|
BOOL has_alpha;
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
HDC hdcSaturated = NULL;
|
HDC hdcSaturated = NULL, hdcSaturatedMask = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!pimldp || !(himl = pimldp->himl)) return FALSE;
|
if (!pimldp || !(himl = pimldp->himl)) return FALSE;
|
||||||
|
@ -1569,12 +1591,12 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
|
||||||
*/
|
*/
|
||||||
if (fState & ILS_SATURATE)
|
if (fState & ILS_SATURATE)
|
||||||
{
|
{
|
||||||
hdcSaturated = saturate_image(himl, pimldp->hdcDst, pimldp->x, pimldp->y,
|
if (saturate_image(himl, pimldp->hdcDst, pimldp->x, pimldp->y,
|
||||||
pt.x, pt.y, cx, cy, pimldp->rgbFg);
|
pt.x, pt.y, cx, cy, pimldp->rgbFg,
|
||||||
|
&hdcSaturated, &hdcSaturatedMask))
|
||||||
if (hdcSaturated != NULL)
|
|
||||||
{
|
{
|
||||||
hImageListDC = hdcSaturated;
|
hImageListDC = hdcSaturated;
|
||||||
|
hMaskListDC = hdcSaturatedMask;
|
||||||
/* shitty way of getting subroutines to blit at the right place (top left corner),
|
/* shitty way of getting subroutines to blit at the right place (top left corner),
|
||||||
as our modified imagelist only contains a single image for performance reasons */
|
as our modified imagelist only contains a single image for performance reasons */
|
||||||
pt.x = 0;
|
pt.x = 0;
|
||||||
|
@ -1604,7 +1626,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
|
||||||
if (bIsTransparent)
|
if (bIsTransparent)
|
||||||
{
|
{
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
bResult = alpha_blend_image( himl, hImageListDC, pimldp->hdcDst, pimldp->x, pimldp->y,
|
bResult = alpha_blend_image( himl, hImageListDC, hMaskListDC, pimldp->hdcDst, pimldp->x, pimldp->y,
|
||||||
#else
|
#else
|
||||||
bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y,
|
bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y,
|
||||||
#endif
|
#endif
|
||||||
|
@ -1618,7 +1640,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
|
||||||
hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour));
|
hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour));
|
||||||
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
|
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
alpha_blend_image( himl, hImageListDC, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func, fStyle, blend_col );
|
alpha_blend_image( himl, hImageListDC, hMaskListDC, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func, fStyle, blend_col );
|
||||||
#else
|
#else
|
||||||
alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func, fStyle, blend_col );
|
alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func, fStyle, blend_col );
|
||||||
#endif
|
#endif
|
||||||
|
@ -1748,6 +1770,8 @@ cleanup:
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
if (hdcSaturated)
|
if (hdcSaturated)
|
||||||
DeleteDC(hdcSaturated);
|
DeleteDC(hdcSaturated);
|
||||||
|
if (hdcSaturatedMask)
|
||||||
|
DeleteDC(hdcSaturatedMask);
|
||||||
#endif
|
#endif
|
||||||
DeleteObject(hBlendMaskBmp);
|
DeleteObject(hBlendMaskBmp);
|
||||||
DeleteObject(hImageBmp);
|
DeleteObject(hImageBmp);
|
||||||
|
|
Loading…
Reference in a new issue