Merge branch 'charlesmchen/normalizeImageColorSpace'

pull/1/head
Matthew Chen 7 years ago
commit a48cc8d652

@ -772,19 +772,15 @@ public class SignalAttachment: NSObject {
assert(newSize.width <= maxSize) assert(newSize.width <= maxSize)
assert(newSize.height <= maxSize) assert(newSize.height <= maxSize)
let bitsPerComponent = cgImage.bitsPerComponent let colorSpace = CGColorSpaceCreateDeviceRGB()
let bytesPerRow = cgImage.bytesPerRow let bitmapInfo: CGBitmapInfo = [
guard let colorSpace = cgImage.colorSpace else { CGBitmapInfo(rawValue: CGImageByteOrderInfo.orderDefault.rawValue),
owsFail("\(logTag) cgImage missing colorSpace.") CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue)]
return nil
}
let bitmapInfo = cgImage.bitmapInfo
guard let context = CGContext.init(data: nil, guard let context = CGContext.init(data: nil,
width: Int(newSize.width), width: Int(newSize.width),
height: Int(newSize.height), height: Int(newSize.height),
bitsPerComponent: bitsPerComponent, bitsPerComponent: 8,
bytesPerRow: bytesPerRow, bytesPerRow: 0,
space: colorSpace, space: colorSpace,
bitmapInfo: bitmapInfo.rawValue) else { bitmapInfo: bitmapInfo.rawValue) else {
owsFail("\(logTag) could not create CGContext.") owsFail("\(logTag) could not create CGContext.")

Loading…
Cancel
Save