Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Merge commit '2cf855b93c84a29c5ceca8d5656907c35992d5d9'
Browse files Browse the repository at this point in the history
  • Loading branch information
ikorich committed Oct 28, 2018
2 parents a603791 + 2cf855b commit 8fda204
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions IGRPhotoTweaks/Category/CGImage+IGRPhotoTweakExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import Foundation

extension CGImage {

func transformedImage(_ transform: CGAffineTransform, sourceSize: CGSize, outputWidth: CGFloat, cropSize: CGSize, imageViewSize: CGSize) -> CGImage {

let aspect: CGFloat = cropSize.height / cropSize.width
let outputSize = CGSize(width: outputWidth, height: (outputWidth * aspect))
func transformedImage(_ transform: CGAffineTransform, zoomScale: CGFloat, sourceSize: CGSize, cropSize: CGSize, imageViewSize: CGSize) -> CGImage {
let expectedWidth = floor(sourceSize.width / imageViewSize.width * cropSize.width) / zoomScale
let expectedHeight = floor(sourceSize.height / imageViewSize.height * cropSize.height) / zoomScale
let outputSize = CGSize(width: expectedWidth, height: expectedHeight)
let bitmapBytesPerRow = 0

let context = CGContext(data: nil,
Expand Down
2 changes: 1 addition & 1 deletion IGRPhotoTweaks/IGRPhotoTweakViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ open class IGRPhotoTweakViewController: UIViewController {

if let fixedImage = self.image.cgImageWithFixedOrientation() {
let imageRef = fixedImage.transformedImage(transform,
zoomScale: self.photoView.scrollView.zoomScale,
sourceSize: self.image.size,
outputWidth: self.image.size.width,
cropSize: self.photoView.cropView.frame.size,
imageViewSize: self.photoView.photoContentView.bounds.size)

Expand Down

0 comments on commit 8fda204

Please sign in to comment.