-
-
Save clmntcrl/8e4cab3ed7d1e7da47e7 to your computer and use it in GitHub Desktop.
Updated it for Swift 2.0 with following code. Seems to work fine so far but you might wanna check!
Thanks!
var pixelData: [CUnsignedChar] = [0, 0, 0, 0]
let bytesPerPixel = 4
let bytesPerRow = bytesPerPixel * 1
let bitsPerComponent = 8
let colorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue | CGBitmapInfo.ByteOrder32Little.rawValue)
let context = CGBitmapContextCreate(&pixelData, 1, 1, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo.rawValue)
CGContextSetBlendMode(context, CGBlendMode.Copy)
Hi, for some reason I get memory error when using this. I have a function that adds 10 buttons with pngs as backgrounds but everytime I click one of the buttons it adds to the memorybuffer an after about 10 clicks the app crash due to memory issues. Do you know what could cause this?
Will this be updated for Swift 3? I'm having trouble getting it functioning.
Is anyone working on swift 3 for this?
Hi All, Here is it in Swift 3 .
https://gist.github.com/rizvvan/d6def79882bda9f916463b2feaeaf64a
I got this
Cannot invoke 'CGBitmapContextCreate' with an argument list of type '(inout [CUnsignedChar], Int, Int, UInt, UInt, CGColorSpace!, CGBitmapInfo)'