Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch #234

Merged

Patch #234

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading