Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

revg

macrumors newbie
Original poster
Aug 14, 2008
9
0
Hi,

I am using Carbon for my lanaguage and I am unable to use Cocoa. Does anyone know how I can convert the bitmap data returned as shown below to a TIFF format in a CFDataRef variable?

Code:
void *data = CGBitmapContextGetData (cgctx);
//how can I now take the bitmap data from the variable data
//and convert it to a CFDataRef in a TIFF format?

Thanks
 

revg

macrumors newbie
Original poster
Aug 14, 2008
9
0
Here is the solution

Code:
void copyCGImageRefToPasteboard(CGImageRef ref)
{
	OSStatus err = noErr; 
	PasteboardRef theClipboard; 
		
	err = PasteboardCreate( kPasteboardClipboard, &theClipboard ); 
	err = PasteboardClear( theClipboard );// 1 
		
	CFMutableDataRef url = CFDataCreateMutable(kCFAllocatorDefault, 0);
		
	CFStringRef type = kUTTypeTIFF;
	size_t count = 1; 
	CFDictionaryRef options = NULL;
	CGImageDestinationRef dest = CGImageDestinationCreateWithData(url, type, count, options);
	CGImageDestinationAddImage(dest, ref, NULL);
	CGImageDestinationFinalize(dest);

	err = PasteboardPutItemFlavor( theClipboard, (PasteboardItemID)1, type, url, 0 ); 
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.