gdiplus: Use StretchBlt instead of GdiAlphaBlend if device doesn't support alpha blending.
This commit is contained in:
parent
1dba866e61
commit
600cbb7874
dlls/gdiplus
|
@ -340,6 +340,30 @@ static void transform_and_round_points(GpGraphics *graphics, POINT *pti,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gdi_alpha_blend(GpGraphics *graphics, INT dst_x, INT dst_y, INT dst_width, INT dst_height,
|
||||||
|
HDC hdc, INT src_x, INT src_y, INT src_width, INT src_height)
|
||||||
|
{
|
||||||
|
if (GetDeviceCaps(graphics->hdc, SHADEBLENDCAPS) == SB_NONE)
|
||||||
|
{
|
||||||
|
TRACE("alpha blending not supported by device, fallback to StretchBlt\n");
|
||||||
|
|
||||||
|
StretchBlt(graphics->hdc, dst_x, dst_y, dst_width, dst_height,
|
||||||
|
hdc, src_x, src_y, src_width, src_height, SRCCOPY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BLENDFUNCTION bf;
|
||||||
|
|
||||||
|
bf.BlendOp = AC_SRC_OVER;
|
||||||
|
bf.BlendFlags = 0;
|
||||||
|
bf.SourceConstantAlpha = 255;
|
||||||
|
bf.AlphaFormat = AC_SRC_ALPHA;
|
||||||
|
|
||||||
|
GdiAlphaBlend(graphics->hdc, dst_x, dst_y, dst_width, dst_height,
|
||||||
|
hdc, src_x, src_y, src_width, src_height, bf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Draw non-premultiplied ARGB data to the given graphics object */
|
/* Draw non-premultiplied ARGB data to the given graphics object */
|
||||||
static GpStatus alpha_blend_pixels(GpGraphics *graphics, INT dst_x, INT dst_y,
|
static GpStatus alpha_blend_pixels(GpGraphics *graphics, INT dst_x, INT dst_y,
|
||||||
const BYTE *src, INT src_width, INT src_height, INT src_stride)
|
const BYTE *src, INT src_width, INT src_height, INT src_stride)
|
||||||
|
@ -370,10 +394,9 @@ static GpStatus alpha_blend_pixels(GpGraphics *graphics, INT dst_x, INT dst_y,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
HBITMAP hbitmap, old_hbm=NULL;
|
HBITMAP hbitmap;
|
||||||
BITMAPINFOHEADER bih;
|
BITMAPINFOHEADER bih;
|
||||||
BYTE *temp_bits;
|
BYTE *temp_bits;
|
||||||
BLENDFUNCTION bf;
|
|
||||||
|
|
||||||
hdc = CreateCompatibleDC(0);
|
hdc = CreateCompatibleDC(0);
|
||||||
|
|
||||||
|
@ -395,17 +418,9 @@ static GpStatus alpha_blend_pixels(GpGraphics *graphics, INT dst_x, INT dst_y,
|
||||||
convert_32bppARGB_to_32bppPARGB(src_width, src_height, temp_bits,
|
convert_32bppARGB_to_32bppPARGB(src_width, src_height, temp_bits,
|
||||||
4 * src_width, src, src_stride);
|
4 * src_width, src, src_stride);
|
||||||
|
|
||||||
old_hbm = SelectObject(hdc, hbitmap);
|
SelectObject(hdc, hbitmap);
|
||||||
|
gdi_alpha_blend(graphics, dst_x, dst_y, src_width, src_height,
|
||||||
bf.BlendOp = AC_SRC_OVER;
|
hdc, 0, 0, src_width, src_height);
|
||||||
bf.BlendFlags = 0;
|
|
||||||
bf.SourceConstantAlpha = 255;
|
|
||||||
bf.AlphaFormat = AC_SRC_ALPHA;
|
|
||||||
|
|
||||||
GdiAlphaBlend(graphics->hdc, dst_x, dst_y, src_width, src_height,
|
|
||||||
hdc, 0, 0, src_width, src_height, bf);
|
|
||||||
|
|
||||||
SelectObject(hdc, old_hbm);
|
|
||||||
DeleteDC(hdc);
|
DeleteDC(hdc);
|
||||||
DeleteObject(hbitmap);
|
DeleteObject(hbitmap);
|
||||||
|
|
||||||
|
@ -918,19 +933,12 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
|
||||||
if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
|
if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
|
||||||
{
|
{
|
||||||
HDC hdc = CreateCompatibleDC(NULL);
|
HDC hdc = CreateCompatibleDC(NULL);
|
||||||
BLENDFUNCTION bf;
|
|
||||||
|
|
||||||
if (!hdc) break;
|
if (!hdc) break;
|
||||||
|
|
||||||
SelectObject(hdc, bmp);
|
SelectObject(hdc, bmp);
|
||||||
|
gdi_alpha_blend(graphics, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
||||||
bf.BlendOp = AC_SRC_OVER;
|
hdc, 0, 0, 1, 1);
|
||||||
bf.BlendFlags = 0;
|
|
||||||
bf.SourceConstantAlpha = 255;
|
|
||||||
bf.AlphaFormat = AC_SRC_ALPHA;
|
|
||||||
|
|
||||||
GdiAlphaBlend(graphics->hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc, 0, 0, 1, 1, bf);
|
|
||||||
|
|
||||||
DeleteDC(hdc);
|
DeleteDC(hdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3288,15 +3296,8 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
|
||||||
|
|
||||||
if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha))
|
if (bitmap->format & (PixelFormatAlpha|PixelFormatPAlpha))
|
||||||
{
|
{
|
||||||
BLENDFUNCTION bf;
|
gdi_alpha_blend(graphics, pti[0].x, pti[0].y, pti[1].x - pti[0].x, pti[2].y - pti[0].y,
|
||||||
|
hdc, srcx, srcy, srcwidth, srcheight);
|
||||||
bf.BlendOp = AC_SRC_OVER;
|
|
||||||
bf.BlendFlags = 0;
|
|
||||||
bf.SourceConstantAlpha = 255;
|
|
||||||
bf.AlphaFormat = AC_SRC_ALPHA;
|
|
||||||
|
|
||||||
GdiAlphaBlend(graphics->hdc, pti[0].x, pti[0].y, pti[1].x-pti[0].x, pti[2].y-pti[0].y,
|
|
||||||
hdc, srcx, srcy, srcwidth, srcheight, bf);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue