I am currently working on a project such as Remote Desktop, in particular, I am trying to provide replacement code for the old methods described above that were used previously. I dealt with this quite successfully, for the most part, but it seems that I have reached a stumbling block.
In OSX 10.7, the call method CGDisplayBaseAddress has been depreciated ( 1 ). This used to give me the base address of the framebuffer in memory, which was used elsewhere to see which parts of the screen were changed and determine what needs to be sent to the remote display. Now it returns NULL.
My current solution was to use CGDisplayCreateImage ( 2 ), which gives me CGImageRef, which I can then use to get a pointer to the raw data (via the CFDataRef object - for code see below) for the image.
Is this the best way to do this? Surely there should be a better way to do this!
To summarize: I donβt want to do any drawing on the screen or anything that Iβm just trying to get a pointer to the first byte in memory that contains either a desktop framebuffer or (as I am doing now) a data image.
Thanks for any help you can give! :)
Current solution code:
CFDataRef copy_image_pixels(CGImageRef inImage) { return CGDataProviderCopyData(CGImageGetDataProvider(inImage)); } void *getPixelDataForImage (CGImageRef image) {
code snippet to get CGImageRef -
osx_disp= main_screen_details->main_screenid; //Returns CGDirectDisplayID CGImageRef screenShot = CGDisplayCreateImage(osx_disp); byte_t *image_byte_data = getPixelDataForImage(screenShot);
byte_t is typedef'd for an unsigned char
source share