I am getting unsupported parameter combination CGBitmap error with swift

I am trying to create a CGContext in swift. It compiles but throws an error at runtime.

let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()
let context:CGContext = CGBitmapContextCreate(nil, 20, 20, 8, 0, colorSpace, CGBitmapInfo.AlphaInfoMask)
CGColorSpaceRelease(colorSpace);

....

And the error is:

Error: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; unrecognized; 96 bytes/row.
fatal error: Can't unwrap Optional.None

Just in case somebody is running into the same problem. The snippet below finally works.

let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue)
let context = CGBitmapContextCreate(nil, UInt(rect.size.width), UInt(rect.size.height), 8, 0, colorSpace, bitmapInfo)

It generates a 32 bit RGBA context in swift

<Error>: CGBitmapContextCreate: unsupported parameter , CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/ component; 16 i'm also getting same issue. i'm using pod version (4.2.3) Because when creating CGBitmapContext, it need to malloc memory buffer with� I originally wrote this App (GitHub) in Obj-C, but need to convert it to Swift. Upon converting I've been having trouble getting the Context for the Bitmap created.

Updated for Swift 3:

    let colorSpace = CGColorSpaceCreateDeviceRGB()
    let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue)
    guard let context = CGContext.init(data: nil, width: Int(size.width), height: Int(size.height), bitsPerComponent: Int(bitsPerComponent), bytesPerRow: Int(bytesPerRow), space: colorSpace, bitmapInfo: UInt32(bitmapInfo.rawValue)) else {
        // cannot create context - handle error
    }

Convert UIImage to UInt8 Array in Swift, I get two errors: CGBitmapContextCreate: unsupported parameter combination: set CGBITMAP_CONTEXT_LOG_ERRORS environmental Any pointers would help a lot, as I'm new to understanding how all of this CGBitmap stuff works. 15 Swift to Objective-C header does not contain Swift classes 13 Strings in Switch Statements: 'String' does not conform to protocol 'IntervalType' 13 UITableView ContentSize when using dynamic height on UITableViewCells

In Swift 2.1 one can access the fields properly, and even OR them together:

let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue | CGBitmapInfo.ByteOrder32Little.rawValue)

let context = CGBitmapContextCreate(baseAddress, width, height, 8,
                bytesPerRow, colorSpace, bitmapInfo.rawValue);

Whole lot of 'rawValue' going on :)

You don't even need to separate out the bitmapInfo, and can do a one-liner:

let context = CGBitmapContextCreate(baseAddress, width, height, 8,
                bytesPerRow, colorSpace, CGImageAlphaInfo.PremultipliedFirst.rawValue | CGBitmapInfo.ByteOrder32Little.rawValue

Get UIImage pixel data? — Xamarin Community Forums, Is there a better way to get the pixel data in a specified format (i.e. RGBA8888) if not then new CGBitmapContext(rawData, width, height, bitsPerComponent, bytesPerRow, I'm guessing that the problem is that you haven't pinned the byte array. Error: CGBitmapContextCreate: unsupported parameter� Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.

Updated for Swift 5:

 let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()
 let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue)
 let context = CGContext(data: nil, width: UInt(rect.size.width), height: UInt(rect.size.height), bitsPerComponent: 8, bytesPerRow: 0, space: colorSpace, bitmapInfo: bitmapInfo.rawValue)

where rect has height and width

intermittent “incorrect checksum for freed object” error on - iOS, Swift 3 CGContext Memory Leak. I'm using a CGBitMapContext() to convert colour spaces to ARGB and get the pixel data values, I malloc space (Full of 0s ) I get two errors: CGBitmapContextCreate: unsupported parameter combination: set� : CGBitmapContextCreate: unsupported parameter combination: set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable to see the details. After setting CGBITMAP_CONTEXT_LOG_ERRORS environment variable, I got more detailed info:: CGBitmapContextCreate: unsupported parameter combination: 16 integer bits/component; 64 bits/pixel;

Suggested way compatible with both Xcode 8.3 and Xcode 9 which supports Swift 3 and Swift 4

let colorSpace = CGColorSpaceCreateDeviceRGB()
guard let bitmapContext = CGContext(data: nil, 
                                    width: Int(size.width),
                                    height: Int(size.height),
                                    bitsPerComponent: Int(bitsPerComponent),
                                    bytesPerRow: Int(bytesPerRow),
                                    space: colorSpace,
                                    bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else {
                                  return nil
    }

ios - Convert UIImage to UInt8 Array in Swift - - Bredeson, i 2 errors: cgbitmapcontextcreate: unsupported parameter combination: set any pointers lot, i'm new understanding how of cgbitmap stuff works. still getting weird error. why?edit: have tried axis=1 well. same result edit 2:� This documentation snippet tells that the aptitute module allows installation from .deb file, like this: # Install a .deb package - apt: deb=/tmp/mypackage.deb. I get the following message when I run it.

[#QTBUG-74530] [Mac] CGBitmapContextCreate: unsupported , [Mac] CGBitmapContextCreate: unsupported parameter combination To reproduce this problem, build and run the code below using Qt� Yeah, you can also try adding -Wno-unused-parameter to your build command line. bobbrow added external question labels Nov 5, 2019 Sign up for free to join this conversation on GitHub .

Blog - Archive - 2017 - December, This power management works by looking at a combination of the device shorten the life” of the phones, all the design parameters were of Apple's choosing. See also: How to get a refund for iTunes or App Store purchases. I mentioned the problem on Twitter a few weeks ago: I'm reading an article in� CGBitmap Context Get Alpha Info Returns the alpha information associated with the context, which indicates how a bitmap context handles the alpha component. CGBitmap Context Get Bits Per Component

bivalve larvae crassostrea: Topics by Science.gov, Shell development and growth of the native mussel, M. californianus, was CgChitinaseLP, CgAMC, CgBMP and CgBMPR in trochophore and D-shape larvae. failed to distinguish the mechanism of failure in highly sensitive bivalve larvae. by simulation of different mortality parameter combinations in a realistic setup,� Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Comments
  • With the current version of Swift (I'm using Xcode 6.1): let bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue)
  • And with the current version of the Xcode is now: let context = CGBitmapContextCreate(nil, Int(rect.size.width), Int(rect.size.height), 8, 0, colorSpace, bitmapInfo)
  • Swift 2.0 actually expects a UInt32 instead of a CGBitMapInfo object, so in Swift 2.0 use let context = CGBitmapContextCreate(nil, Int(rect.size.width), Int(rect.size.height), 8, 0, colorSpace, bitmapInfo.rawValue). <- notice how we convert CGBitMapInfo to UInt32 by using its rawValue
  • Swift 2 let context = CGBitmapContextCreate(nil, width, height, bitsPerComponent, bytesPerRow, colourSpace, CGBitmapInfo.ByteOrder32Little.rawValue)
  • I want to use other that PremultipliedLast but if I am using none, first or last context become nil
  • This does not compile and i can not find CGBitmapInfo.AlphaLast or CGBitmapInfo.AlphaFirst in developer.apple.com/library/prerelease/ios/documentation/…