Skip to content

Commit f98e969

Browse files
codeman9niilohlin
authored andcommitted
Use the correct scale for the diff image (pointfreeco#472)
1 parent 46bc930 commit f98e969

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/SnapshotTesting/Snapshotting/UIImage.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ private func context(for cgImage: CGImage, bytesPerRow: Int, data: UnsafeMutable
130130
private func diff(_ old: UIImage, _ new: UIImage) -> UIImage {
131131
let width = max(old.size.width, new.size.width)
132132
let height = max(old.size.height, new.size.height)
133-
UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), true, 0)
133+
let scale = max(old.scale, new.scale)
134+
UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), true, scale)
134135
new.draw(at: .zero)
135136
old.draw(at: .zero, blendMode: .difference, alpha: 1)
136137
let differenceImage = UIGraphicsGetImageFromCurrentImageContext()!

0 commit comments

Comments
 (0)