Skip to content

Commit

Permalink
Done
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuyuni committed Sep 19, 2023
1 parent 6735893 commit b1e34f1
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
E17BDAED2AB74BA100EBACD0 /* ReproductCGImageRotates.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ReproductCGImageRotates.app; sourceTree = BUILT_PRODUCTS_DIR; };
E17BDAED2AB74BA100EBACD0 /* ReproduceCGImageRotates.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ReproduceCGImageRotates.app; sourceTree = BUILT_PRODUCTS_DIR; };
E17BDAF02AB74BA100EBACD0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
E17BDAF22AB74BA100EBACD0 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
E17BDAF42AB74BA100EBACD0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -40,20 +40,20 @@
E17BDAE42AB74BA100EBACD0 = {
isa = PBXGroup;
children = (
E17BDAEF2AB74BA100EBACD0 /* ReproductCGImageRotates */,
E17BDAEF2AB74BA100EBACD0 /* ReproduceCGImageRotates */,
E17BDAEE2AB74BA100EBACD0 /* Products */,
);
sourceTree = "<group>";
};
E17BDAEE2AB74BA100EBACD0 /* Products */ = {
isa = PBXGroup;
children = (
E17BDAED2AB74BA100EBACD0 /* ReproductCGImageRotates.app */,
E17BDAED2AB74BA100EBACD0 /* ReproduceCGImageRotates.app */,
);
name = Products;
sourceTree = "<group>";
};
E17BDAEF2AB74BA100EBACD0 /* ReproductCGImageRotates */ = {
E17BDAEF2AB74BA100EBACD0 /* ReproduceCGImageRotates */ = {
isa = PBXGroup;
children = (
E17BDAF02AB74BA100EBACD0 /* AppDelegate.swift */,
Expand All @@ -64,15 +64,15 @@
E17BDAFB2AB74BA200EBACD0 /* LaunchScreen.storyboard */,
E17BDAFE2AB74BA200EBACD0 /* Info.plist */,
);
path = ReproductCGImageRotates;
path = ReproduceCGImageRotates;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
E17BDAEC2AB74BA100EBACD0 /* ReproductCGImageRotates */ = {
E17BDAEC2AB74BA100EBACD0 /* ReproduceCGImageRotates */ = {
isa = PBXNativeTarget;
buildConfigurationList = E17BDB012AB74BA200EBACD0 /* Build configuration list for PBXNativeTarget "ReproductCGImageRotates" */;
buildConfigurationList = E17BDB012AB74BA200EBACD0 /* Build configuration list for PBXNativeTarget "ReproduceCGImageRotates" */;
buildPhases = (
E17BDAE92AB74BA100EBACD0 /* Sources */,
E17BDAEA2AB74BA100EBACD0 /* Frameworks */,
Expand All @@ -82,9 +82,9 @@
);
dependencies = (
);
name = ReproductCGImageRotates;
name = ReproduceCGImageRotates;
productName = ReproductCGImageRotates;
productReference = E17BDAED2AB74BA100EBACD0 /* ReproductCGImageRotates.app */;
productReference = E17BDAED2AB74BA100EBACD0 /* ReproduceCGImageRotates.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand All @@ -102,7 +102,7 @@
};
};
};
buildConfigurationList = E17BDAE82AB74BA100EBACD0 /* Build configuration list for PBXProject "ReproductCGImageRotates" */;
buildConfigurationList = E17BDAE82AB74BA100EBACD0 /* Build configuration list for PBXProject "ReproduceCGImageRotates" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
Expand All @@ -115,7 +115,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
E17BDAEC2AB74BA100EBACD0 /* ReproductCGImageRotates */,
E17BDAEC2AB74BA100EBACD0 /* ReproduceCGImageRotates */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -289,7 +289,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 6XX6PGKBH6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ReproductCGImageRotates/Info.plist;
INFOPLIST_FILE = ReproduceCGImageRotates/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
Expand All @@ -300,7 +300,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = works.tsuyu.ReproductCGImageRotates;
PRODUCT_BUNDLE_IDENTIFIER = works.tsuyu.ReproduceCGImageRotates;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -317,7 +317,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 6XX6PGKBH6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ReproductCGImageRotates/Info.plist;
INFOPLIST_FILE = ReproduceCGImageRotates/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
Expand All @@ -328,7 +328,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = works.tsuyu.ReproductCGImageRotates;
PRODUCT_BUNDLE_IDENTIFIER = works.tsuyu.ReproduceCGImageRotates;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -339,7 +339,7 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
E17BDAE82AB74BA100EBACD0 /* Build configuration list for PBXProject "ReproductCGImageRotates" */ = {
E17BDAE82AB74BA100EBACD0 /* Build configuration list for PBXProject "ReproduceCGImageRotates" */ = {
isa = XCConfigurationList;
buildConfigurations = (
E17BDAFF2AB74BA200EBACD0 /* Debug */,
Expand All @@ -348,7 +348,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
E17BDB012AB74BA200EBACD0 /* Build configuration list for PBXNativeTarget "ReproductCGImageRotates" */ = {
E17BDB012AB74BA200EBACD0 /* Build configuration list for PBXNativeTarget "ReproduceCGImageRotates" */ = {
isa = XCConfigurationList;
buildConfigurations = (
E17BDB022AB74BA200EBACD0 /* Debug */,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>ReproduceCGImageRotates.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>ReproductCGImageRotates.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AppDelegate.swift
// ReproductCGImageRotates
// ReproduceCGImageRotates
//
// Created by Yuri Tsuchikawa on 2023/09/17.
//
Expand Down
58 changes: 58 additions & 0 deletions ReproduceCGImageRotates/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="ReproduceCGImageRotates" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="FOd-4T-zfP">
<rect key="frame" x="0.0" y="119" width="393" height="393"/>
<constraints>
<constraint firstAttribute="width" secondItem="FOd-4T-zfP" secondAttribute="height" multiplier="1:1" id="Nfy-W9-5j7"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uqd-9p-LpO">
<rect key="frame" x="132" y="612" width="129.33333333333337" height="35"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="gray" title="Open Camera"/>
<connections>
<action selector="onTapOpenCamera:" destination="BYZ-38-t0r" eventType="touchUpInside" id="3os-Rh-qvo"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="uqd-9p-LpO" firstAttribute="top" secondItem="FOd-4T-zfP" secondAttribute="bottom" constant="100" id="JdH-yp-njC"/>
<constraint firstItem="FOd-4T-zfP" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="L3O-nr-pjB"/>
<constraint firstItem="FOd-4T-zfP" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="60" id="LPy-LZ-w7J"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="FOd-4T-zfP" secondAttribute="trailing" id="OhV-iW-x7c"/>
<constraint firstItem="uqd-9p-LpO" firstAttribute="centerX" secondItem="FOd-4T-zfP" secondAttribute="centerX" id="qkg-8m-GHI"/>
</constraints>
</view>
<connections>
<outlet property="imageView" destination="FOd-4T-zfP" id="5w1-ZQ-sB7"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-25.190839694656489" y="-27.464788732394368"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSCameraUsageDescription</key>
<string></string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SceneDelegate.swift
// ReproductCGImageRotates
// ReproduceCGImageRotates
//
// Created by Yuri Tsuchikawa on 2023/09/17.
//
Expand Down
51 changes: 51 additions & 0 deletions ReproduceCGImageRotates/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// ViewController.swift
// ReproduceCGImageRotates
//
// Created by Yuri Tsuchikawa on 2023/09/17.
//

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var imageView: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()

}

@IBAction func onTapOpenCamera(_ sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(.camera) {
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .camera
imagePicker.delegate = self
self.present(imagePicker, animated: true)
}
}
}

extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true)
guard let image = info[.originalImage] as? UIImage, let cgImage = image.cgImage, let fixedCGImage = image.fixedCGImage else { return }
print(cgImage.width, cgImage.height) // Normal CGImage which rotates
print(fixedCGImage.width, fixedCGImage.height) // Fixed CGImage which NOT rotates
imageView.image = UIImage(cgImage: fixedCGImage)
}
}

extension UIImage {

var fixedCGImage: CGImage? {
get {
UIGraphicsBeginImageContext(self.size)
let context = UIGraphicsGetCurrentContext()
self.draw(at: .zero)
let image = UIGraphicsGetImageFromCurrentImageContext()
return image?.cgImage
}
}
}

This file was deleted.

24 changes: 0 additions & 24 deletions ReproductCGImageRotates/Base.lproj/Main.storyboard

This file was deleted.

19 changes: 0 additions & 19 deletions ReproductCGImageRotates/ViewController.swift

This file was deleted.

0 comments on commit b1e34f1

Please sign in to comment.