I created the following context (simplified):
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate (bitmapData, pixWide, pixHeigh, 8,
Now when I try to extract data for the first pixel in my PNG using Alphatransparency, it has very strange alpha values. I have a simple PNG, square. On each edge, I cut off 10x10 pixels and made them completely transparent. Alpha should not be something like 153.
KCGImageAlphaOnly is declared in cGImage.h. Doc says:
kCGImageAlphaOnly No data color, only alpha channel.
Good, so it's really good, because I only need Alpha data, and nothing more. But that raises some question marks in my head. If I use a fully equipped PNG with a bunch of colors + alpha: will this constant check that my PNG is converted to match this color space? Or do I need to provide a PNG that matches the specified color space?
Edit: I tried using kCGImageAlphaOnly, but I get this error:
<Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 24 bits/pixel; 0-component colorspace; kCGImageAlphaOnly; 55 bytes/row.
What could be the problem? I indicated this before:
size_t pixelsWide = CGImageGetWidth(inImage); size_t pixelsHigh = CGImageGetHeight(inImage); bitmapBytesPerRow = (pixelsWide * 1);
Edit: I read this a minute ago:
PNGs added to Xcode are optimized "pngcrush" during compilation. It does some bytes (from RGBA to BRGA) and pre-multiply alpha.
I assume that this pre-multiplication of alpha creates problems.
Edit: alpha channel remains intact after pngcrunch has performed byte exchange in PNG. I don't care about colors, just alpha, I think that pre-multiplication should not be too big a problem.
My PNG was a 24-bit PNG bevor. I added them to Xcode.