Bass said:
Bass said:
*snip*
Per chance, does anyone here know if a call to LockBits() prohibits the bitmap object from being garbage collected?
I am thinking of perhaps a much more efficent way to do this, passing the pointer bmp.LockBits().Scan0
Why does it matter if LockBits prevents the bitmap from being collected? If you want it to be collected then Dispose it. If you don't want to be collected then keep a reference to it. In any case, if you call LockBits you should also call UnlockBits:
BitmapData bmpData = bmp.LockBits(...);
Secrat.Sause.ProperitaryPixelFormat pixbuf = new Secrat.Sause.Bmp.Loader(bmpData.Scan0);
bmp.UnlockBits(bmpData);
Of course, if the Loader doesn't make a copy of the pixels you'll have to make one yourself.
PS:
The MemoryStream code sample: you may want to set the stream position to 0 after you save the bitmap. If the "loader" doesn't do it then it's no wonder you get "Invalid bitmap, no header".
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.