-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from jasonjmcghee/fix-timeline-loading
careful profiling, fixing timeline loading, auto-pause recording on open timeline
- Loading branch information
Showing
6 changed files
with
145 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// ImageHelper.swift | ||
// rem | ||
// | ||
// Created by Jason McGhee on 12/31/23. | ||
// | ||
|
||
import Foundation | ||
import os | ||
import SwiftUI | ||
|
||
class ImageHelper { | ||
private static let logger = Logger( | ||
subsystem: Bundle.main.bundleIdentifier!, | ||
category: String(describing: ImageHelper.self) | ||
) | ||
|
||
// Useful for debugging... | ||
static func pngData(from nsImage: NSImage) -> Data? { | ||
guard let tiffRepresentation = nsImage.tiffRepresentation, | ||
let bitmapImage = NSBitmapImageRep(data: tiffRepresentation) else { | ||
logger.error("Failed to get TIFF representation of NSImage") | ||
return nil | ||
} | ||
|
||
guard let pngData = bitmapImage.representation(using: .png, properties: [:]) else { | ||
logger.error("Failed to convert NSImage to PNG") | ||
return nil | ||
} | ||
|
||
return pngData | ||
} | ||
|
||
static func saveNSImage(image: NSImage, path: String) { | ||
let pngData = pngData(from: image) | ||
do { | ||
if let savedir = RemFileManager.shared.getSaveDir() { | ||
let outputPath = savedir.appendingPathComponent("\(path).png").path | ||
let fileURL = URL(fileURLWithPath: outputPath) | ||
try pngData?.write(to: fileURL) | ||
logger.info("PNG file written successfully") | ||
} else { | ||
logger.error("Error writing PNG file") | ||
} | ||
} catch { | ||
logger.error("Error writing PNG file: \(error)") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.