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

Commit

Permalink
Crop area does not scale when image is rotated 90 degrees. #24
Browse files Browse the repository at this point in the history
  • Loading branch information
ikorich committed Oct 28, 2018
1 parent b756778 commit 3bf69ba
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 208 deletions.
174 changes: 0 additions & 174 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
A5FE19461E4F553600EA6F73 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19431E4F553600EA6F73 /* AppDelegate.swift */; };
A5FE19471E4F553600EA6F73 /* ExampleCropViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19441E4F553600EA6F73 /* ExampleCropViewController.swift */; };
A5FE19481E4F553600EA6F73 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19451E4F553600EA6F73 /* ViewController.swift */; };
A5FE19511E4F6ECE00EA6F73 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19501E4F6ECE00EA6F73 /* main.m */; };
A5FE19541E4F6ECE00EA6F73 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19531E4F6ECE00EA6F73 /* AppDelegate.m */; };
A5FE19571E4F6ECE00EA6F73 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19561E4F6ECE00EA6F73 /* ViewController.m */; };
A5FE195A1E4F6ECE00EA6F73 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A5FE19581E4F6ECE00EA6F73 /* Main.storyboard */; };
A5FE19661E4F726F00EA6F73 /* ExampleCropViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19651E4F726F00EA6F73 /* ExampleCropViewController.m */; };
C31BBE2B1F6DF26E57CED1FE /* Pods_ExampleObjC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E001388CF0AFFB056DC06E8 /* Pods_ExampleObjC.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -36,16 +30,6 @@
A5FE19431E4F553600EA6F73 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = SOURCE_ROOT; };
A5FE19441E4F553600EA6F73 /* ExampleCropViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleCropViewController.swift; sourceTree = SOURCE_ROOT; };
A5FE19451E4F553600EA6F73 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = SOURCE_ROOT; };
A5FE194D1E4F6ECE00EA6F73 /* ExampleObjC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleObjC.app; sourceTree = BUILT_PRODUCTS_DIR; };
A5FE19501E4F6ECE00EA6F73 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
A5FE19521E4F6ECE00EA6F73 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
A5FE19531E4F6ECE00EA6F73 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
A5FE19551E4F6ECE00EA6F73 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
A5FE19561E4F6ECE00EA6F73 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
A5FE19591E4F6ECE00EA6F73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
A5FE19641E4F726F00EA6F73 /* ExampleCropViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleCropViewController.h; sourceTree = "<group>"; };
A5FE19651E4F726F00EA6F73 /* ExampleCropViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleCropViewController.m; sourceTree = "<group>"; };
A5FE196E1E4F870900EA6F73 /* IGRPhotoTweaks-Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IGRPhotoTweaks-Swift.h"; sourceTree = "<group>"; };
B5E4CDA77E8F904599EAFE3C /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand All @@ -58,14 +42,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A5FE194A1E4F6ECE00EA6F73 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C31BBE2B1F6DF26E57CED1FE /* Pods_ExampleObjC.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand All @@ -82,7 +58,6 @@
isa = PBXGroup;
children = (
A5DFB1C71E481FE4009ACD31 /* Example */,
A5FE194E1E4F6ECE00EA6F73 /* ExampleObjC */,
A5DFB1CB1E481FE4009ACD31 /* Resources */,
A5DFB1D11E481FE4009ACD31 /* Settings */,
A5DFB1B31E481F48009ACD31 /* Products */,
Expand All @@ -95,7 +70,6 @@
isa = PBXGroup;
children = (
A5DFB1B21E481F48009ACD31 /* Example.app */,
A5FE194D1E4F6ECE00EA6F73 /* ExampleObjC.app */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -128,30 +102,6 @@
path = Settings;
sourceTree = "<group>";
};
A5FE194E1E4F6ECE00EA6F73 /* ExampleObjC */ = {
isa = PBXGroup;
children = (
A5FE19521E4F6ECE00EA6F73 /* AppDelegate.h */,
A5FE19531E4F6ECE00EA6F73 /* AppDelegate.m */,
A5FE19551E4F6ECE00EA6F73 /* ViewController.h */,
A5FE19561E4F6ECE00EA6F73 /* ViewController.m */,
A5FE19641E4F726F00EA6F73 /* ExampleCropViewController.h */,
A5FE19651E4F726F00EA6F73 /* ExampleCropViewController.m */,
A5FE19581E4F6ECE00EA6F73 /* Main.storyboard */,
A5FE194F1E4F6ECE00EA6F73 /* Supporting Files */,
A5FE196E1E4F870900EA6F73 /* IGRPhotoTweaks-Swift.h */,
);
path = ExampleObjC;
sourceTree = "<group>";
};
A5FE194F1E4F6ECE00EA6F73 /* Supporting Files */ = {
isa = PBXGroup;
children = (
A5FE19501E4F6ECE00EA6F73 /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
D0C927687C190AB5C9A48AE6 /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -186,25 +136,6 @@
productReference = A5DFB1B21E481F48009ACD31 /* Example.app */;
productType = "com.apple.product-type.application";
};
A5FE194C1E4F6ECE00EA6F73 /* ExampleObjC */ = {
isa = PBXNativeTarget;
buildConfigurationList = A5FE19631E4F6ECE00EA6F73 /* Build configuration list for PBXNativeTarget "ExampleObjC" */;
buildPhases = (
FAF484DFF2853C7C099CC5DF /* [CP] Check Pods Manifest.lock */,
A5FE19491E4F6ECE00EA6F73 /* Sources */,
A5FE194A1E4F6ECE00EA6F73 /* Frameworks */,
A5FE194B1E4F6ECE00EA6F73 /* Resources */,
BED4765AF2FDF8358050E039 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = ExampleObjC;
productName = ExampleObjC;
productReference = A5FE194D1E4F6ECE00EA6F73 /* ExampleObjC.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -222,12 +153,6 @@
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
A5FE194C1E4F6ECE00EA6F73 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = DMP42GVPJ3;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = A5DFB1AD1E481F48009ACD31 /* Build configuration list for PBXProject "Example" */;
Expand All @@ -244,7 +169,6 @@
projectRoot = "";
targets = (
A5DFB1B11E481F48009ACD31 /* Example */,
A5FE194C1E4F6ECE00EA6F73 /* ExampleObjC */,
);
};
/* End PBXProject section */
Expand All @@ -260,14 +184,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A5FE194B1E4F6ECE00EA6F73 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A5FE195A1E4F6ECE00EA6F73 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -302,26 +218,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
BED4765AF2FDF8358050E039 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-ExampleObjC/Pods-ExampleObjC-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/HorizontalDial/HorizontalDial.framework",
"${BUILT_PRODUCTS_DIR}/IGRPhotoTweaks/IGRPhotoTweaks.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HorizontalDial.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/IGRPhotoTweaks.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleObjC/Pods-ExampleObjC-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
DD24609E454B4037F6F9D18F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -342,24 +238,6 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
FAF484DFF2853C7C099CC5DF /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-ExampleObjC-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -373,17 +251,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A5FE19491E4F6ECE00EA6F73 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A5FE19571E4F6ECE00EA6F73 /* ViewController.m in Sources */,
A5FE19661E4F726F00EA6F73 /* ExampleCropViewController.m in Sources */,
A5FE19541E4F6ECE00EA6F73 /* AppDelegate.m in Sources */,
A5FE19511E4F6ECE00EA6F73 /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
Expand All @@ -403,14 +270,6 @@
name = Main.storyboard;
sourceTree = "<group>";
};
A5FE19581E4F6ECE00EA6F73 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
A5FE19591E4F6ECE00EA6F73 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -541,30 +400,6 @@
};
name = Release;
};
A5FE19611E4F6ECE00EA6F73 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3D9A19D6F45607DA91F31157 /* Pods-ExampleObjC.debug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = DMP42GVPJ3;
INFOPLIST_FILE = "$(SRCROOT)/Settings/Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = com.igrsoft.ExampleObjC;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
A5FE19621E4F6ECE00EA6F73 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 91908735A031EC6576B9A740 /* Pods-ExampleObjC.release.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = DMP42GVPJ3;
INFOPLIST_FILE = "$(SRCROOT)/Settings/Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = com.igrsoft.ExampleObjC;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand All @@ -586,15 +421,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A5FE19631E4F6ECE00EA6F73 /* Build configuration list for PBXNativeTarget "ExampleObjC" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A5FE19611E4F6ECE00EA6F73 /* Debug */,
A5FE19621E4F6ECE00EA6F73 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = A5DFB1AA1E481F48009ACD31 /* Project object */;
Expand Down
5 changes: 2 additions & 3 deletions Example/ExampleCropViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ class ExampleCropViewController: IGRPhotoTweakViewController {
@IBAction func onChandeAngleSliderValue(_ sender: UISlider) {
let radians: CGFloat = CGFloat(sender.value)
setupAngleLabelValue(radians: radians)
self.changedAngle(value: radians)

self.changeAngle(radians: radians)
}

@IBAction func onEndTouchAngleControl(_ sender: UIControl) {
Expand Down Expand Up @@ -190,7 +189,7 @@ extension ExampleCropViewController: HorizontalDialDelegate {
let radians = IGRRadianAngle.toRadians(CGFloat(degrees))

self.setupAngleLabelValue(radians: radians)
self.changedAngle(value: radians)
self.changeAngle(radians: radians)
}

func horizontalDialDidEndScroll(_ horizontalDial: HorizontalDial) {
Expand Down
4 changes: 2 additions & 2 deletions Example/ExampleObjC/ExampleCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (void)setupAngleLabelValue:(CGFloat)radians {
- (IBAction)onChandeAngleSliderValue:(UISlider *)sender {
CGFloat radians = sender.value;
[self setupAngleLabelValue:radians];
[self changedAngleWithValue:radians];
[self changeAngleWithValue:radians];
}

- (IBAction)onEndTouchAngleControl:(UIControl *)sender {
Expand All @@ -73,7 +73,7 @@ - (IBAction)onEndTouchAngleControl:(UIControl *)sender {
- (IBAction)onChandeAnglePickerViewValue:(UIPickerView *)sender {
CGFloat radians = CGFloat.zero;
[self setupAngleLabelValue:radians];
[self changedAngleWithValue:radians];
[self changeAngleWithValue:radians];
}

- (IBAction)onTouchResetButton:(UIButton *)sender {
Expand Down
6 changes: 3 additions & 3 deletions IGRPhotoTweaks/Category/CGImage+IGRPhotoTweakExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ extension CGImage {
context?.concatenate(transform)
context?.scaleBy(x: 1.0, y: -1.0)
context?.draw(self, in: CGRect(x: (-imageViewSize.width.half),
y: (-imageViewSize.height.half),
width: imageViewSize.width,
height: imageViewSize.height))
y: (-imageViewSize.height.half),
width: imageViewSize.width,
height: imageViewSize.height))

let result = context!.makeImage()!

Expand Down
4 changes: 2 additions & 2 deletions IGRPhotoTweaks/IGRPhotoTweakViewController+Angle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import Foundation

extension IGRPhotoTweakViewController {
public func changedAngle(value: CGFloat) {
self.photoView.changedAngle(value: value)
public func changeAngle(radians: CGFloat) {
self.photoView.changeAngle(radians: radians)
}

public func stopChangeAngle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import Photos

extension IGRPhotoTweakViewController {

internal func saveToLibrary(image: UIImage) {
let writePhotoToLibraryBlock: (() -> Void)? = {
UIImageWriteToSavedPhotosAlbum(image, self, #selector(self.image(image:didFinishSavingWithError:contextInfo:)), nil)
Expand Down
2 changes: 1 addition & 1 deletion IGRPhotoTweaks/IGRPhotoTweakViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ open class IGRPhotoTweakViewController: UIViewController {
let translation: CGPoint = self.photoView.photoTranslation
transform = transform.translatedBy(x: translation.x, y: translation.y)
// rotate
transform = transform.rotated(by: self.photoView.angle)
transform = transform.rotated(by: self.photoView.radians)
// scale

let t: CGAffineTransform = self.photoView.photoContentView.transform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension IGRCropView {
width: frame.size.width,
height: newHeight)
}

//TODO: Added test cropViewInsideValidFrame

if (frame.size.width > self.cornerBorderLength
Expand Down
Loading

0 comments on commit 3bf69ba

Please sign in to comment.