Skip to content

Commit

Permalink
fix: fix the issue of output size does not match the crop ratio (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyingtao committed Jan 30, 2023
1 parent 48d2a52 commit 459aa77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/Mantis/Extensions/CGImageExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ extension CGImage {
}

guard let context = CGContext(data: nil,
width: Int(outputSize.width),
height: Int(outputSize.height),
width: Int(round(outputSize.width)),
height: Int(round(outputSize.height)),
bitsPerComponent: bitsPerComponent,
bytesPerRow: bitmapBytesPerRow,
space: colorSpaceRef,
Expand Down
4 changes: 2 additions & 2 deletions Sources/Mantis/Extensions/UIImageExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ extension UIImage {
let cropSize = cropInfo.cropSize
let imageViewSize = cropInfo.imageViewSize

let expectedWidth = floor(size.width / imageViewSize.width * cropSize.width) / zoomScaleX
let expectedHeight = floor(size.height / imageViewSize.height * cropSize.height) / zoomScaleY
let expectedWidth = round((size.width / imageViewSize.width * cropSize.width) / zoomScaleX)
let expectedHeight = round((size.height / imageViewSize.height * cropSize.height) / zoomScaleY)

return CGSize(width: expectedWidth, height: expectedHeight)
}
Expand Down

0 comments on commit 459aa77

Please sign in to comment.