I am getting unsupported parameter combination CGBitmap error with swift
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
Cannot invoke initializer for type 'CGBitmapInfo' with an argument list of type '(UInt32)'
In the current version of Swift, the final parameter of CGBitmapContextCreate
is a UInt32
, so in place of CGBitmapInfo(options)
above, you should just pass options
(the expression assigned to options
is inferred to have type UInt32
).
What's wrong when i custom an imageView by OpenGLES?
If a non zero buffer object is bound, then the 5th parameter of glVertexAttribPointer
is treated as a byte offset into the buffer object's data store.
So the offset to the texture coordinates is MemoryLayout<GLfloat>.size * 3
:
glVertexAttribPointer(..., BUFFER_OFFSET(3))
glVertexAttribPointer(GLuint(textCoor), 2, GLenum(GL_FLOAT), GLboolean(GL_FALSE),
GLsizei(MemoryLayout<GLfloat>.size * 5), BUFFER_OFFSET(MemoryLayout<GLfloat>.size * 3))
How to set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable?
Environmental variables can be set in the product scheme editor (in Xcode) like shown in the screenshot:
Product > Scheme > Edit Scheme... (⌘<)
Can't get bytes for a non-square image
It was pretty easy to solve, actually, here's the problem part:
for x in 0..<width {
for y in 0..<height {
let byteIndex = (bytesPerRow * x) + y * bytesPerPixel
And here's how it's supposed to be:
for y in 0..<height {
for x in 0..<width {
let byteIndex = (bytesPerRow * y) + x * bytesPerPixel
I do not think this needs any further explanation.
Related Topics
Find Size Contributed by Each External Library on iOS
Delete a Device from My Developer Account to Increase the Count
Status Bar Visible on iPad Mini Despite Setting Uiviewcontrollerbasedstatusbarappearance to No
Zip and Unzip a File Programmatically in iOS
Autorelease Pools and When Release Is Called Under iOS
Encryption with Rsa Public Key on iOS
Set Delegates to Nil Under Arc
Generating Custom Thumbnail from Alassetrepresentation
Easiest Way of Getting Reverse Geocoded Current Location from iOS
Playing Video into Uitableview
How to Pass Data to Another Controller on Dismiss Viewcontroller
Save Eventually on Pfobject with Pffile (Parse Local Datastore)
Xcode 8 Gm Seed Storyboard Layout Issue
"The Run Destination iOS Device Is Not Valid for Running the Scheme"
Check If an Auto-Renewable Subscription Is Still Valid
#Import <Libxml/Tree.H> File Not Found After Xcode Update
iPad iOS7 - Uiimagepickercontroller in Uipopovercontroller Has Wrong Preview Image