Created
July 11, 2016 20:31
-
-
Save ccgus/e8df08c1ab0c3643cf5010923be4885e to your computer and use it in GitHub Desktop.
ugh
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
import Cocoa | |
import ImageIO | |
import CoreGraphics | |
var cs = CGColorSpaceCreateDeviceRGB(); | |
var bitmapOptions = CGBitmapInfo.byteOrder16Little.rawValue | CGImageAlphaInfo.premultipliedLast.rawValue; | |
var bitmapContext = CGContext(data: nil, width: 10, height: 10, bitsPerComponent: 16, bytesPerRow: 0, space: cs, bitmapInfo: bitmapOptions); | |
var img = bitmapContext!.makeImage(); | |
var data = NSMutableData(); | |
var imageDestination = CGImageDestinationCreateWithData(data, kUTTypeTIFF, 1, nil); | |
CGImageDestinationAddImage(imageDestination!, img!, nil); | |
let worked = CGImageDestinationFinalize(imageDestination!); | |
var imageSourceRef = CGImageSourceCreateWithData(data, nil) | |
var imageRef = CGImageSourceCreateImageAtIndex(imageSourceRef!, 0, NSDictionary()); | |
imageRef!.bitsPerComponent; | |
assert(imageRef!.bitsPerComponent == 16) | |
NSLog("Done.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment