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

ruhi

macrumors member
Original poster
Jun 17, 2009
70
0
Hello,

I have a CGImageRef which i have created by:

CGImageRef screenShot = CGWindowListCreateImage(bound , kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault );

This CGImageRef is now used to create NSBitmapImageRep:

NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];

data=[bitmapRep representationUsingType:NSJPEGFileType properties:[NSDictionary dictionaryWithObject:NSImageCompressionMethod forKey:mad:"compression"]];

Now i have the image data with me, i want change the color depth per pixel to 256 colors or 32 bit, How can i do that?

Thanks,
Ruhi.
 
You have the JPEG data, not the image data. Those are two different things.

I believe what you might need to do is create a new NSBitmapImageRep with your specified settings (or use a CGBitmapContext) and then draw your existing image into that new bitmap. Then, you can get a JPEG representation to write it to file.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.