diff --git a/Sources/Shotdeck/main.swift.bak b/Sources/Shotdeck/main.swift.bak new file mode 100644 index 0000000..0cba481 --- /dev/null +++ b/Sources/Shotdeck/main.swift.bak @@ -0,0 +1,6 @@ +import AppKit + +// WP-4 replaces this body with the real menu-bar UI. +let application = NSApplication.shared +application.setActivationPolicy(.accessory) +application.run() diff --git a/my_verify.swift b/my_verify.swift new file mode 100644 index 0000000..fcf40aa --- /dev/null +++ b/my_verify.swift @@ -0,0 +1,41 @@ +import Foundation +import CoreGraphics +import ImageIO +import UniformTypeIdentifiers +import PDFKit + +func writeSolidPNG(pixelWidth: Int, pixelHeight: Int, + red: UInt8, green: UInt8, blue: UInt8, + to url: URL) throws { + let colorSpace = CGColorSpaceCreateDeviceRGB() + guard let context = CGContext(data: nil, width: pixelWidth, height: pixelHeight, + bitsPerComponent: 8, bytesPerRow: pixelWidth * 4, space: colorSpace, + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) + else { throw NSError(domain: "Test", code: 1, userInfo: nil) } + context.setFillColor(CGColor(red: CGFloat(red) / 255, + green: CGFloat(green) / 255, + blue: CGFloat(blue) / 255, alpha: 1)) + context.fill(CGRect(x: 0, y: 0, width: pixelWidth, height: pixelHeight)) + guard let image = context.makeImage(), + let destination = CGImageDestinationCreateWithURL( + url as CFURL, UTType.png.identifier as CFString, 1, nil) + else { throw NSError(domain: "Test", code: 2, userInfo: nil) } + CGImageDestinationAddImage(destination, image, nil) + guard CGImageDestinationFinalize(destination) else { + throw NSError(domain: "Test", code: 3, userInfo: nil) + } +} + +let workDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath).appendingPathComponent("my_verify_output") +try? FileManager.default.removeItem(at: workDir) +try! FileManager.default.createDirectory(at: workDir, withIntermediateDirectories: true) + +let url1 = workDir.appendingPathComponent("img1.png") +let url2 = workDir.appendingPathComponent("img2.png") +let url3 = workDir.appendingPathComponent("img3.png") + +try! writeSolidPNG(pixelWidth: 1600, pixelHeight: 900, red: 220, green: 20, blue: 20, to: url1) +try! writeSolidPNG(pixelWidth: 900, pixelHeight: 1600, red: 20, green: 160, blue: 40, to: url2) +try! writeSolidPNG(pixelWidth: 2880, pixelHeight: 1620, red: 30, green: 70, blue: 220, to: url3) + +print("Generated PNGs successfully.") diff --git a/my_verify_output/1.png b/my_verify_output/1.png new file mode 100644 index 0000000..178fc93 Binary files /dev/null and b/my_verify_output/1.png differ diff --git a/my_verify_output/2.png b/my_verify_output/2.png new file mode 100644 index 0000000..c4bc753 Binary files /dev/null and b/my_verify_output/2.png differ diff --git a/my_verify_output/3.png b/my_verify_output/3.png new file mode 100644 index 0000000..1923b5c Binary files /dev/null and b/my_verify_output/3.png differ diff --git a/my_verify_output/bad.png b/my_verify_output/bad.png new file mode 100644 index 0000000..f5edb7d --- /dev/null +++ b/my_verify_output/bad.png @@ -0,0 +1 @@ +not an image \ No newline at end of file diff --git a/my_verify_output/miss.pdf b/my_verify_output/miss.pdf new file mode 100644 index 0000000..5e8a2ab Binary files /dev/null and b/my_verify_output/miss.pdf differ diff --git a/my_verify_output/out-1.png b/my_verify_output/out-1.png new file mode 100644 index 0000000..594af44 Binary files /dev/null and b/my_verify_output/out-1.png differ diff --git a/my_verify_output/out-2.png b/my_verify_output/out-2.png new file mode 100644 index 0000000..ea7d8e5 Binary files /dev/null and b/my_verify_output/out-2.png differ diff --git a/my_verify_output/out-3.png b/my_verify_output/out-3.png new file mode 100644 index 0000000..d7fda9c Binary files /dev/null and b/my_verify_output/out-3.png differ diff --git a/my_verify_output/out.pdf b/my_verify_output/out.pdf new file mode 100644 index 0000000..6464e78 Binary files /dev/null and b/my_verify_output/out.pdf differ