Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5106 #5142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

#5106 #5142

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions ChartsDemo-iOS/ChartsDemo-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,12 @@
225B361C1F6EB9A50005B3D5 = {
CreatedOnToolsVersion = 9.0;
LastSwiftMigration = 1150;
ProvisioningStyle = Manual;
};
5B57BBAE1A9B26AA0036A6CC = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 1150;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -890,6 +891,7 @@
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Manual;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand All @@ -898,6 +900,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.dcg.ChartsDemo-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -921,6 +924,7 @@
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
Expand All @@ -930,6 +934,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.dcg.ChartsDemo-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
Expand Down Expand Up @@ -1046,7 +1051,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand All @@ -1069,7 +1074,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand Down
23 changes: 17 additions & 6 deletions Source/Charts/Utils/Platform+Graphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,31 @@ func NSUIGraphicsPopContext()
NSGraphicsContext.restoreGraphicsState()
}

func NSUIImagePNGRepresentation(_ image: NSUIImage) -> Data?
func NSUIImagePNGRepresentation(_ image: NSUIImage, inView view: NSUIView) -> Data?
{
image.lockFocus()
let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height))

let tRep = view.bitmapImageRepForCachingDisplay(in: NSRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
if let rep = tRep {
view.cacheDisplay(in: NSRect(x: 0, y: 0, width: image.size.width, height: image.size.height), to: rep)
return rep.representation(using: .png, properties: [:])
}
image.unlockFocus()
return rep?.representation(using: .png, properties: [:])
return tRep?.representation(using: .png, properties: [:])
}

func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.9) -> Data?
func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.9, inView view: NSUIView) -> Data?
{
image.lockFocus()
let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height))

let tRep = view.bitmapImageRepForCachingDisplay(in: NSRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
if let rep = tRep {
view.cacheDisplay(in: NSRect(x: 0, y: 0, width: image.size.width, height: image.size.height), to: rep)
return rep.representation(using: .jpeg, properties: [NSBitmapImageRep.PropertyKey.compressionFactor: quality])
}

image.unlockFocus()
return rep?.representation(using: .jpeg, properties: [NSBitmapImageRep.PropertyKey.compressionFactor: quality])
return tRep?.representation(using: .jpeg, properties: [NSBitmapImageRep.PropertyKey.compressionFactor: quality])
}

private var imageContextStack: [CGFloat] = []
Expand Down