mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-21 18:09:24 +01:00
* Make bitblt and stretchblt alpha aware. In case of an alpha source or destination our alpha aware stretchmaskblt is used to blit a dc. (fixes #11694)
git-svn-id: trunk@15893 -
This commit is contained in:
parent
277a9e21e0
commit
e1b010411a
@ -120,6 +120,8 @@ procedure FillRawImageDescription(const ABitmapInfo: Windows.TBitmap; out ADesc:
|
||||
|
||||
function GetBitmapOrder(AWinBmp: Windows.TBitmap; ABitmap: HBITMAP):TRawImageLineOrder;
|
||||
function GetBitmapBytes(AWinBmp: Windows.TBitmap; ABitmap: HBITMAP; const ARect: TRect; ALineEnd: TRawImageLineEnd; ALineOrder: TRawImageLineOrder; out AData: Pointer; out ADataSize: PtrUInt): Boolean;
|
||||
function IsAlphaBitmap(ABitmap: HBITMAP): Boolean;
|
||||
function IsAlphaDC(ADC: HDC): Boolean;
|
||||
|
||||
procedure BlendRect(ADC: HDC; const ARect: TRect; Color: ColorRef);
|
||||
function GetLastErrorText(AErrorCode: Cardinal): String;
|
||||
@ -1545,6 +1547,21 @@ begin
|
||||
FreeMem(SrcData);
|
||||
end;
|
||||
|
||||
function IsAlphaBitmap(ABitmap: HBITMAP): Boolean;
|
||||
var
|
||||
Info: Windows.BITMAP;
|
||||
begin
|
||||
FillChar(Info, SizeOf(Info), 0);
|
||||
Result := (GetObject(ABitmap, SizeOf(Info), @Info) <> 0)
|
||||
and (Info.bmBitsPixel = 32);
|
||||
end;
|
||||
|
||||
function IsAlphaDC(ADC: HDC): Boolean;
|
||||
begin
|
||||
Result := (GetObjectType(ADC) = OBJ_MEMDC)
|
||||
and IsAlphaBitmap(GetCurrentObject(ADC, OBJ_BITMAP));
|
||||
end;
|
||||
|
||||
procedure BlendRect(ADC: HDC; const ARect: TRect; Color: ColorRef);
|
||||
var
|
||||
bmp, oldBmp: HBitmap;
|
||||
|
||||
@ -100,7 +100,10 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TWin32WidgetSet.BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean;
|
||||
begin
|
||||
Result := Boolean(Windows.BitBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, Rop));
|
||||
// use stretchmaskblt for alpha images, since that one is customized for alpha
|
||||
if IsAlphaDC(DestDC) or IsAlphaDC(SrcDC)
|
||||
then Result := StretchMaskBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, Width, Height, 0, 0, 0, Rop)
|
||||
else Result := Windows.BitBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, Rop);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -3053,9 +3056,10 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TWin32WidgetSet.StretchBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc, SrcWidth, SrcHeight: Integer; Rop: Cardinal): Boolean;
|
||||
begin
|
||||
Assert(True, Format('Trace:> [TWin32WidgetSet.StretchBlt] DestDC:0x%x; X:%d, Y:%d, Width:%d, Height:%d; SrcDC:0x%x; XSrc:%d, YSrc:%d, SrcWidth:%d, SrcHeight:%d; Rop:0x%x', [DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, SrcWidth, SrcHeight, Rop]));
|
||||
Result := Boolean(Windows.StretchBlt(DestDc, X, Y, Width, Height, SrcDC, XSrc, YSrc, SrcWidth, SrcHeight, Rop));
|
||||
Assert(True, Format('Trace:< [TWin32WidgetSet.StretchBlt] DestDC:0x%x --> %s', [DestDC, BOOL_TEXT[Result]]));
|
||||
// use stretchmaskblt for alpha images, since that one is customized for alpha
|
||||
if IsAlphaDC(DestDC) or IsAlphaDC(SrcDC)
|
||||
then Result := StretchMaskBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, SrcWidth, SrcHeight, 0, 0, 0, Rop)
|
||||
else Result := Windows.StretchBlt(DestDc, X, Y, Width, Height, SrcDC, XSrc, YSrc, SrcWidth, SrcHeight, Rop);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user