         let context = CGBitmapContextCreate(data.mutableBytes, Int(size.width), Int(size.height), 8, 4 * Int(size.width), CGColorSpaceCreateDeviceRGB(), bitmapInfo)!
         CGContextDrawImage(context, CGRect(origin: .zero, size:size), image.CGImage)
         let bytes = UnsafeMutablePointer<UInt8>(data.mutableBytes)
+        
         let start = NSDate()
         for i in 0..<(data.length/4) {
             let (r, g, b) = (CGFloat(bytes[i*4])/255, CGFloat(bytes[i*4+1])/255, CGFloat(bytes[i*4+2])/255)

        bitmapInfo |= CGImageAlphaInfo.PremultipliedLast.rawValue & CGBitmapInfo.AlphaInfoMask.rawValue
        let context = CGBitmapContextCreate(data.mutableBytes, Int(size.width), Int(size.height), 8, 4 * Int(size.width), CGColorSpaceCreateDeviceRGB(), bitmapInfo)!
        CGContextDrawImage(context, CGRect(origin: .zero, size:size), image.CGImage)
        let bytes = UnsafeMutablePointer<UInt8>(data.mutableBytes)
        
        let dataBuffer = device.newBufferWithBytes(bytes, length: data.length, options: [])
        let cmdBuffer:MTLCommandBuffer = {
            let queue = device.newCommandQueue()
            let cmdBuffer = queue.commandBuffer()
            let encoder = cmdBuffer.computeCommandEncoder(); defer { encoder.endEncoding() }

            return cmdBuffer
        }()
        
        cmdBuffer.commit()
        cmdBuffer.waitUntilCompleted()
        let end = NSDate()
        print("SNTrim GPU \(size), \(end.timeIntervalSinceDate(start))")
        maskImage = UIImage(CGImage: CGBitmapContextCreateImage(context)!)
    }

