mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 11:39:55 +02:00
Cocoa: fix transparent image drawing , issue #41131
This commit is contained in:
parent
3bdd810b85
commit
b12de1fee6
@ -281,7 +281,6 @@ type
|
|||||||
procedure ReCreateHandle_IfModified();
|
procedure ReCreateHandle_IfModified();
|
||||||
procedure SetModified();
|
procedure SetModified();
|
||||||
function CreateSubImage(const ARect: TRect): CGImageRef;
|
function CreateSubImage(const ARect: TRect): CGImageRef;
|
||||||
function CreateMaskImage(const ARect: TRect): CGImageRef;
|
|
||||||
procedure PreMultiplyAlpha();
|
procedure PreMultiplyAlpha();
|
||||||
function GetNonPreMultipliedData(): PByte;
|
function GetNonPreMultipliedData(): PByte;
|
||||||
public
|
public
|
||||||
@ -1081,22 +1080,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TCocoaBitmap.CreateMaskImage(const ARect: TRect): CGImageRef;
|
|
||||||
var
|
|
||||||
CGDataProvider: CGDataProviderRef;
|
|
||||||
Mask: CGImageRef;
|
|
||||||
begin
|
|
||||||
CGDataProvider := CGDataProviderCreateWithData(nil, FData, FDataSize, nil);
|
|
||||||
try
|
|
||||||
Mask := CGImageMaskCreate(FWidth, FHeight, FBitsPerPixel,
|
|
||||||
FBitsPerPixel, FBytesPerRow, CGDataProvider, nil, 0);
|
|
||||||
Result := CGImageCreateWithImageInRect(Mask, RectToCGRect(ARect));
|
|
||||||
finally
|
|
||||||
CGDataProviderRelease(CGDataProvider);
|
|
||||||
CGImageRelease(Mask);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCocoaBitmap.GetColorSpace: NSString;
|
function TCocoaBitmap.GetColorSpace: NSString;
|
||||||
begin
|
begin
|
||||||
if FType in [cbtMono, cbtGray] then
|
if FType in [cbtMono, cbtGray] then
|
||||||
@ -2166,7 +2149,6 @@ function TCocoaContext.StretchDraw(X, Y, Width, Height: Integer;
|
|||||||
Msk: TCocoaBitmap; XMsk, YMsk: Integer; Rop: DWORD): Boolean;
|
Msk: TCocoaBitmap; XMsk, YMsk: Integer; Rop: DWORD): Boolean;
|
||||||
var
|
var
|
||||||
Bmp: TCocoaBitmap;
|
Bmp: TCocoaBitmap;
|
||||||
MskImage: CGImageRef = nil;
|
|
||||||
ImgRect: CGRect;
|
ImgRect: CGRect;
|
||||||
|
|
||||||
dcWidth: Integer;
|
dcWidth: Integer;
|
||||||
@ -2188,12 +2170,6 @@ begin
|
|||||||
inc(YSrc, -SrcDC.WindowOfs.Y);
|
inc(YSrc, -SrcDC.WindowOfs.Y);
|
||||||
|
|
||||||
CGContextSaveGState(CGContext);
|
CGContextSaveGState(CGContext);
|
||||||
//apply window offset
|
|
||||||
if (Msk <> nil) and (Msk.Image <> nil) then begin
|
|
||||||
MskImage := Msk.CreateMaskImage(Bounds(XMsk, YMsk, SrcWidth, SrcHeight));
|
|
||||||
ImgRect := CGRectMake(x, y, dcWidth, dcHeight);
|
|
||||||
CGContextClipToMask(CGContext, ImgRect, MskImage);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if NOT SrcDC.ctx.isFlipped then begin
|
if NOT SrcDC.ctx.isFlipped then begin
|
||||||
YSrc := Bmp.Height - (SrcHeight + YSrc);
|
YSrc := Bmp.Height - (SrcHeight + YSrc);
|
||||||
@ -2201,8 +2177,6 @@ begin
|
|||||||
|
|
||||||
Result := DrawImageRep(GetNSRect(X, Y, Width, Height),GetNSRect(XSrc, YSrc, SrcWidth, SrcHeight), bmp.ImageRep);
|
Result := DrawImageRep(GetNSRect(X, Y, Width, Height),GetNSRect(XSrc, YSrc, SrcWidth, SrcHeight), bmp.ImageRep);
|
||||||
|
|
||||||
if Assigned(MskImage) then
|
|
||||||
CGImageRelease(MskImage);
|
|
||||||
CGContextRestoreGState(CGContext);
|
CGContextRestoreGState(CGContext);
|
||||||
|
|
||||||
AttachedBitmap_SetModified();
|
AttachedBitmap_SetModified();
|
||||||
|
Loading…
Reference in New Issue
Block a user