mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-12 00:03:27 +01:00
Supports landscape app screenshots
Rotates landscape screenshots before displaying them. For now, we still assume screenshots have 16:9 aspect ratio.
This commit is contained in:
@@ -138,7 +138,8 @@ private extension AppContentViewController
|
||||
}
|
||||
dataSource.prefetchHandler = { (imageURL, indexPath, completionHandler) in
|
||||
return RSTAsyncBlockOperation() { (operation) in
|
||||
ImagePipeline.shared.loadImage(with: imageURL as URL, progress: nil, completion: { (response, error) in
|
||||
let request = ImageRequest(url: imageURL as URL, processor: .screenshot)
|
||||
ImagePipeline.shared.loadImage(with: request, progress: nil, completion: { (response, error) in
|
||||
guard !operation.isCancelled else { return operation.finish() }
|
||||
|
||||
if let image = response?.image
|
||||
|
||||
@@ -53,7 +53,8 @@ private extension BrowseCollectionViewCell
|
||||
}
|
||||
dataSource.prefetchHandler = { (imageURL, indexPath, completionHandler) in
|
||||
return RSTAsyncBlockOperation() { (operation) in
|
||||
ImagePipeline.shared.loadImage(with: imageURL as URL, progress: nil, completion: { (response, error) in
|
||||
let request = ImageRequest(url: imageURL as URL, processor: .screenshot)
|
||||
ImagePipeline.shared.loadImage(with: request, progress: nil, completion: { (response, error) in
|
||||
guard !operation.isCancelled else { return operation.finish() }
|
||||
|
||||
if let image = response?.image
|
||||
|
||||
25
AltStore/Types/ScreenshotProcessor.swift
Normal file
25
AltStore/Types/ScreenshotProcessor.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// ScreenshotProcessor.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 4/11/22.
|
||||
// Copyright © 2022 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Nuke
|
||||
|
||||
struct ScreenshotProcessor: ImageProcessing
|
||||
{
|
||||
func process(image: Image, context: ImageProcessingContext) -> Image?
|
||||
{
|
||||
guard let cgImage = image.cgImage, image.size.width > image.size.height else { return image }
|
||||
|
||||
let rotatedImage = UIImage(cgImage: cgImage, scale: image.scale, orientation: .right)
|
||||
return rotatedImage
|
||||
}
|
||||
}
|
||||
|
||||
extension ImageProcessing where Self == ScreenshotProcessor
|
||||
{
|
||||
static var screenshot: Self { Self() }
|
||||
}
|
||||
Reference in New Issue
Block a user