Skip to content

Commit

Permalink
Patch (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Mar 29, 2024
1 parent 80e5b94 commit a1b3f21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions Sources/BrightroomEngine/Core/EditingStack.Edit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extension EditingStack {
crop.imageSize
}

/// In orientation.up
public var crop: EditingCrop
public var filters: Filters = .init()
public var drawings: Drawings = .init()
Expand Down
14 changes: 10 additions & 4 deletions Sources/BrightroomEngine/Core/EditingStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,21 +412,27 @@ open class EditingStack: Hashable, StoreComponentType {
public func makeCroppedCIImage(loadedState: State.Loaded) -> CIImage {

do {
let orientation = loadedState.metadata.orientation
let crop = loadedState.currentEdit.crop

// orientation is not respected
let image = loadedState.editingSourceCGImage
let imageSize = image.size


// orientation-respected
let imageSize = image.size
.applying(cgOrientation: orientation)

let scaledCrop = crop.scaledWithPixelPerfect(
maxPixelSize: max(imageSize.width, imageSize.height)
)

return try image
.oriented(orientation)
.croppedWithColorspace(
to: scaledCrop.cropExtent, adjustmentAngleRadians: scaledCrop.aggregatedRotation.radians)
to: scaledCrop.cropExtent, adjustmentAngleRadians: scaledCrop.aggregatedRotation.radians
)
._makeCIImage(
orientation: loadedState.metadata.orientation,
orientation: .up,
device: mtlDevice,
usesMTLTexture: options.usesMTLTextureForEditingImage
)
Expand Down

0 comments on commit a1b3f21

Please sign in to comment.