Bitmap and MemoryStream

M

MLM450

I am creating a bitmap using a memory stream. Is there any way to load
the bitmap data so the memory stream can be disposed? Perhaps copying
the bitmap in some simple, quick way?

Thanks
 
M

Michael Phillips, Jr.

The stream must remain open for the life of the bitmap. However, you may
create a new bitmap with the same width, height and pixel format and then
use DrawImage to create a copy, then you may dispose of the stream. This
only works for non indexed bitmaps. For indexed bitmaps, you must use
LockBits to marshal the bits from the old bitmap to the new one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top