Shared memory problem

Hello,

Apologies if this gets a little long…

I’ve got a program which uses shared memory to hold a PhImage_t so one background process can compose the image, send a message to a GUI app to display it. This works fine if I compose the image drawing commands like PgDrawPhImagemx(&position, image, NULL) after doing PmMemStart(context) to redirect drawing from the screen to a memory context, which contains the image. However, this turns out not to be fast enough for my needs, so I’m now pre-composing all the images I need into their own contexts, and once all images are composed (30 images) I memcpy the image (and image->image data) into the image in shared memory. This is plenty fast enough for me now, but the image in shared memory will now only display in the background process in which they were created, and not in the GUI app for which they were intended (it just displays black).

I guess the memcpy copies local pointers from the background app into shared memory, which are invalid in the GUI app, but work fine in the background app where they were created. So my question is… How can I copy an image into shared memory in the same that PgDrawPhImagemx can draw into it, without messing it up?

Thanks, if some of the above is a bit vague, I’d be happy to try and explain in greater detail.

Garry

Keep your local structures and the data they point at separate. The shared memory can only be used for the image data, not for the structures since the memory will likely live at different addresses in each process.