Producing CCITT compressed TIFF from CGImage

Posted by Brian Postow on Stack Overflow See other posts from Stack Overflow or by Brian Postow
Published on 2009-04-16T22:14:04Z Indexed on 2010/05/17 1:30 UTC
Read the original article Hit count: 422

Filed under:
|
|
|

I have a CGImage (core graphics, C/C++). It's grayscale. Well, originally it was B/W, but the CGImage may be RGB. That shouldn't matter. I want to create a CCITT-Group 4 TIFF.

I can create an LZW TIFF (grayscale or color) via creating a destination with the correct dictionary and adding the image in. No problem.

However, there doesn't seem to be an equivalent kCGImagePropertyTIFFCompression value to represent CCITT-4. It should be 4, but that produces uncompressed.

I have a manual CCITT compression routine, so if I can get the binary (1 bit per pixel) data, I'm set. But I can't seem to get 1 BPP data out of a CGImage. I have code that is supposed to put the CGImage into a CGBitmapContext and then give me the data, but it seems to be giving me all black.

I've asked a couple of questions today trying to get at this, but I just figured, lets ask the question I REALLY want answered and see if someone can answer it.

There's GOT to be a way to do this. I've got to be missing something dumb. What is it?

© Stack Overflow or respective owner

Related posts about mac

Related posts about core-graphics