mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-29 10:19:27 +01:00
Correct image resize adjustment for scaling up images
This commit is contained in:
parent
f7dec4cf23
commit
a90930c7f9
@ -39,7 +39,11 @@ struct IconImageView: View {
|
|||||||
let newSize: CGSize
|
let newSize: CGSize
|
||||||
|
|
||||||
if imageSize.height == imageSize.width {
|
if imageSize.height == imageSize.width {
|
||||||
return imageSize
|
if imageSize.height >= viewSize.height {
|
||||||
|
newSize = CGSize(width: viewSize.width, height: viewSize.height)
|
||||||
|
} else {
|
||||||
|
newSize = CGSize(width: imageSize.width, height: imageSize.height)
|
||||||
|
}
|
||||||
} else if imageSize.height > imageSize.width {
|
} else if imageSize.height > imageSize.width {
|
||||||
let factor = viewSize.height / imageSize.height
|
let factor = viewSize.height / imageSize.height
|
||||||
let width = imageSize.width * factor
|
let width = imageSize.width * factor
|
||||||
|
@ -100,6 +100,9 @@ private extension IconView {
|
|||||||
let imageSize = image.size
|
let imageSize = image.size
|
||||||
let viewSize = bounds.size
|
let viewSize = bounds.size
|
||||||
if imageSize.height == imageSize.width {
|
if imageSize.height == imageSize.width {
|
||||||
|
if imageSize.height >= viewSize.height {
|
||||||
|
return CGRect(x: 0.0, y: 0.0, width: viewSize.width, height: viewSize.height)
|
||||||
|
}
|
||||||
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
||||||
return CGRect(x: offset, y: offset, width: imageSize.width, height: imageSize.height)
|
return CGRect(x: offset, y: offset, width: imageSize.width, height: imageSize.height)
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,9 @@ private extension IconView {
|
|||||||
let imageSize = image.size
|
let imageSize = image.size
|
||||||
let viewSize = bounds.size
|
let viewSize = bounds.size
|
||||||
if imageSize.height == imageSize.width {
|
if imageSize.height == imageSize.width {
|
||||||
|
if imageSize.height >= viewSize.height {
|
||||||
|
return NSMakeRect(0.0, 0.0, viewSize.width, viewSize.height)
|
||||||
|
}
|
||||||
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
||||||
return NSMakeRect(offset, offset, imageSize.width, imageSize.height)
|
return NSMakeRect(offset, offset, imageSize.width, imageSize.height)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user