Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17 from teambition/fix/miniMap-orientation
Browse files Browse the repository at this point in the history
fix incorrect image orientation in miniMap
  • Loading branch information
D-Wang authored Jun 22, 2019
2 parents b5583bd + 7874b3e commit 20c1a10
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions PhotoBrowser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
4A7E8F3E224A16A6005B54C8 /* ImageContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A7E8F3D224A16A6005B54C8 /* ImageContainerView.swift */; };
4A8A90962244C27D00A09C55 /* HighResolutionImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8A90952244C27D00A09C55 /* HighResolutionImageView.swift */; };
4A8EB7291CEF16020065EAB0 /* PBActionBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8EB7281CEF16020065EAB0 /* PBActionBarItem.swift */; };
4ABA2F1F22B8929600DB589C /* UIImage+Resize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ABA2F1E22B8929600DB589C /* UIImage+Resize.swift */; };
864F45E81E9F0A4900FF9215 /* Skitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864F45E71E9F0A4900FF9215 /* Skitch.swift */; };
86AEF7301EDEC8A000034DBA /* SkitchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AEF72F1EDEC8A000034DBA /* SkitchView.swift */; };
A18117E01E83B66900F8CE8E /* CustomPhotoBroswerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A18117DF1E83B66900F8CE8E /* CustomPhotoBroswerManager.swift */; };
Expand Down Expand Up @@ -67,6 +68,7 @@
4A7E8F3D224A16A6005B54C8 /* ImageContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageContainerView.swift; sourceTree = "<group>"; };
4A8A90952244C27D00A09C55 /* HighResolutionImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HighResolutionImageView.swift; sourceTree = "<group>"; };
4A8EB7281CEF16020065EAB0 /* PBActionBarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PBActionBarItem.swift; sourceTree = "<group>"; };
4ABA2F1E22B8929600DB589C /* UIImage+Resize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Resize.swift"; sourceTree = "<group>"; };
864F45E71E9F0A4900FF9215 /* Skitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Skitch.swift; sourceTree = "<group>"; };
86AEF72F1EDEC8A000034DBA /* SkitchView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SkitchView.swift; sourceTree = "<group>"; };
A18117DF1E83B66900F8CE8E /* CustomPhotoBroswerManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomPhotoBroswerManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -182,6 +184,7 @@
C4C79EA02057808200C92C0C /* UIView+Frame.swift */,
C4B64B622117E95300B29C5B /* UIViewController+Animation.swift */,
4A70A002225308A100DBD070 /* Kingfisher+CacheSerializer.swift */,
4ABA2F1E22B8929600DB589C /* UIImage+Resize.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -456,6 +459,7 @@
4A8EB7291CEF16020065EAB0 /* PBActionBarItem.swift in Sources */,
C4B64B5D2117E90000B29C5B /* DismissAnimation.swift in Sources */,
C4B64B652117EA6300B29C5B /* PBConstant.swift in Sources */,
4ABA2F1F22B8929600DB589C /* UIImage+Resize.swift in Sources */,
A18117E01E83B66900F8CE8E /* CustomPhotoBroswerManager.swift in Sources */,
86AEF7301EDEC8A000034DBA /* SkitchView.swift in Sources */,
);
Expand Down
21 changes: 21 additions & 0 deletions PhotoBrowser/Extensions/UIImage+Resize.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UIImage+Resize.swift
// PhotoBrowser
//
// Created by WangWei on 2019/6/18.
// Copyright © 2019 Teambition. All rights reserved.
//

import UIKit

extension UIImage {
func resize(to size: CGSize) -> UIImage {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
let context = UIGraphicsGetCurrentContext()
draw(in: CGRect(origin: .zero, size: size))
guard let cgImage = context?.makeImage() else {
return self
}
return UIImage(cgImage: cgImage)
}
}
3 changes: 2 additions & 1 deletion PhotoBrowser/PhotoPreview/PhotoPreviewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ extension PhotoPreviewController {
let pointSize = miniMapSize
DispatchQueue.global().async { [weak self] in
// downsample image to minimap size to reduce memory cost
let downsampled = image.kf.resize(to: pointSize, for: .aspectFit)
let targetSize = image.size.kf.resize(to: pointSize, for: .aspectFit)
let downsampled = image.resize(to: targetSize)
DispatchQueue.main.async {
self?.miniMap?.image = downsampled
}
Expand Down

0 comments on commit 20c1a10

Please sign in to comment.