HatchStyle drawing does not allow color change.
Original Reporter info from Mantis: djenkins @dfjenkins
-
Reporter name: David Jenkins
Original Reporter info from Mantis: djenkins @dfjenkins
- Reporter name: David Jenkins
Description:
TCocoaBrush.SetHatchStyle() is using FImage created from Bitmap.ImageRep.CGImageFOrProposedRect) as the hatch pattern bitmap. This image is not a mask (check FImage.isMask()). Cocoa interprets this to mean that the pattern bitmap will do it's own coloring and ignores the color information set up with NSPatternColorSpace. So the pattern will always draw black and white with heavy black.
For NSPatternColorSpace to work the pattern CGImage needs to be a mask. This can be created with CGImageMaskCreate and an Dataprovider.
Additional information:
Patch
Index: Lazarus/laz-src/lcl/interfaces/cocoa/cocoagdiobjects.pas =================================================================== --- Lazarus/laz-src/lcl/interfaces/cocoa/cocoagdiobjects.pas (revision 22741) +++ Lazarus/laz-src/lcl/interfaces/cocoa/cocoagdiobjects.pas (working copy)
@@ -2862,6 +2866,7 @@
);
var
ACallBacks: CGPatternCallbacks;
+ CGDataProvider: CGDataProviderRef;
begin
if AHatch in [HS_HORIZONTAL..HS_DIAGCROSS] then
begin
@@ -2870,7 +2875,9 @@
if (FBitmap <> nil) then FBitmap.Release;
FBitmap := TCocoaBitmap.Create(8, 8, 1, 1, cbaByte, cbtMask, @HATCH_DATA[AHatch]);
if FImage <> nil then CGImageRelease(FImage);
- FImage := CGImageCreateCopy(MacOSAll.CGImageRef( FBitmap.ImageRep.CGImageForProposedRect_context_hints(nil, nil, nil)));
+ CGDataProvider := CGDataProviderCreateWithData(nil, @HATCH_DATA[AHatch], 8, nil);
+ FImage := CGImageMaskCreate(8, 8, 1, 1, 1, CGDataProvider, nil, 0);
+ CGDataProviderRelease(CGDataProvider);
FColored := False;
if FCGPattern <> nil then CGPatternRelease(FCGPattern);
FCGPattern := CGPatternCreate(Self, GetCGRect(0, 0, 8, 8),
Mantis conversion info:
- Mantis ID: 32825
- Fixed in revision: 61047 (#8e3bac19)