Most efficient way to send images across processes Most efficient way to send images across processes windows windows

Most efficient way to send images across processes


Use a Memory Mapped File.

For a Delphi reference see Memory-mapped Files in Delphi and Shared Memory in Delphi.

For a more versatile approach you can look at using pipes or sending bitmap data via TCP. This would allow you to distribute the image data between nodes more easily, if necessary.


Use shared memory to pass the image data, and something else (named pipes, sockets, ...) to coordinate the handover.


In some cases, you can pass HBITMAP handles across processes. I've seen it done before (yes, on XP/Vista), and was surprised as everyone else on the team when one of my co-workers showed me.

If memory serves me correctly, I believe it will work if the HBITMAP was allocated with one of the GDI function (CreateBitmap, CreateCompatibleBitmap,CreateDIBitmap,etc...) HBIMAP handles created by LoadBitmap will not work as it's just a pointer to an in-proc resource.

That, and I think when you share the HBITMAP across to the other process, don't try to do anything special with it other than normal BitBlt operations.

At least that's what I remember. We got lucky because our graphic libraries were already written to manage all images as HBITMAPs.

YMMV