fix: sharper images on non-retina displays

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-03-10 14:00:37 +09:00
1 parent a2bb19ffcb
commit 1bb4d2a1c8
3 files changed
+16 -4

No files matched your search

+12
View File
@@ -161,3 +161,15 @@ extension NSControl {
}
}
}
extension NSImage {
// copy and resize an image using high quality interpolation
func resizedCopy(_ width: CGFloat, _ height: CGFloat) -> NSImage {
let img = NSImage(size: CGSize(width: width, height: height))
img.lockFocus()
NSGraphicsContext.current?.imageInterpolation = .high
draw(in: NSMakeRect(0, 0, width, height), from: NSMakeRect(0, 0, size.width, size.height), operation: .copy, fraction: 1)
img.unlockFocus()
return img
}
}
+2 -2
View File
@@ -26,8 +26,8 @@ class FeedbackWindow: NSWindow {
}
private func setupView() {
let appIcon = NSImageView(image: App.shared.applicationIconImage)
appIcon.fit(80, 80)
let appIcon = NSImageView(image: NSImage(named: "app-icon")!.resizedCopy(80, 80))
appIcon.imageScaling = .scaleNone
let appText = NSStackView(views: [
BoldLabel(NSLocalizedString("Share improvement ideas, or report bugs", comment: "")),
HyperlinkLabel(NSLocalizedString("View existing discussions", comment: ""), App.repository + "/issues"),
@@ -6,8 +6,8 @@ class AboutTab: NSObject {
}
static func makeView() -> NSGridView {
let appIcon = NSImageView(image: App.shared.applicationIconImage)
appIcon.fit(150, 150)
let appIcon = NSImageView(image: NSImage(named: "app-icon")!.resizedCopy(150, 150))
appIcon.imageScaling = .scaleNone
let appText = NSStackView(views: [
BoldLabel(App.name),
NSTextField(wrappingLabelWithString: NSLocalizedString("Version", comment: "") + " " + App.version),