cocoa: #32749. invalidating (and discarding) the original non-premultiplied data, if it has been modified by NSBitmapContext in NSImageRep. Changing bitmap handle recreation prior to drawing the bitmap. The change has been tested with samples from #28692 and #28102.

git-svn-id: trunk@56715 -
This commit is contained in:
dmitry 2017-12-14 06:44:51 +00:00
parent c35b4b0f90
commit eda7fd2cd0

View File

@ -989,6 +989,12 @@ end;
procedure TCocoaBitmap.SetModified;
begin
if FOriginalData <> nil then
begin
// the original data no longer applies, as imageRep was modified
System.FreeMem(FOriginalData);
FOriginalData:=nil;
end;
FModified_SinceLastRecreate := True;
end;
@ -2095,6 +2101,9 @@ begin
if not Assigned(Bmp) then
Exit(False);
// Make sure that bitmap is the most up-to-date
Bmp.ReCreateHandle_IfModified(); // Fix for bug 28102
if (Msk <> nil) and (Msk.Image <> nil) then
begin
MskImage := Msk.CreateMaskImage(Bounds(XMsk, YMsk, SrcWidth, SrcHeight));
@ -2110,14 +2119,12 @@ begin
CGImageRelease(MskImage);
CGContextRestoreGState(CGContext);
Bmp.ReCreateHandle_IfModified(); // Fix for bug 28102
end
else
begin
// convert Y coordinate of the source bitmap
YSrc := Bmp.Height - (SrcHeight + YSrc);
Result := DrawImageRep(GetNSRect(X, Y, Width, Height),GetNSRect(XSrc, YSrc, SrcWidth, SrcHeight), bmp.ImageRep);
Bmp.ReCreateHandle_IfModified(); // Fix for bug 28102
end;
AttachedBitmap_SetModified();
end;