I assume you are concerned about allocating an unnecessary object. I think such concern is commendable.

What you are probably after is an Bitmap API where the bytes of the PNG image is provided through Stream<byte> and the Bitmap API then produces when needed by the socket.

System.Drawing doesn't seem to support such behavior, possibly WIC does (.NET wrappers exists through the excellent SharpDX library).

However, this would mean keeping potentially expensive objects (bitmap, brushes and so on) alive for the duration of the transfer. The byte array might be a more efficient way to store the result.

Another approach in order to avoid allocating objects unnecessarily is caching them. It's made a bit more problematic because System.Drawing objects are mutable and not safe to use from multiple threads. You can however create a cache per thread using ThreadLocal .

In the sample code below most objects are cached per Thread . The only object created per call to draw is the byte array returned but that is probably an efficient storage of the PNG data (it's possible the calls System.Drawing allocates objects but we have no control over that). As I didn't figure out a way to listen for the "death" of a Thread it means it's important to manually dispose the objects using the dispose method when the Thread no longer needs the objects.

Hope this was interesting