Getting the Size of an In-Memory Bitmap

I have an image compression utility and I want to let users know the size of the compressed image they're about to save.

How can I programmatically predict the file size of an in-memory bitmap without actually writing a file to disk? I'm using GDI+ of course.
LVL 8
boulder_bumAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexFMCommented:
Save image to MemoryStream and get it's size.
I don't know what image compression utility do you use. I can guess that any .NET component which can write to file, can write also to stream.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
boulder_bumAuthor Commented:
That seems like a viable solution. Thanks!

The image compression utility is actually something I cooked up myself so I have full control over any tweaks.

I'll test when I get home and deal with the points or follow-up then.
0
boulder_bumAuthor Commented:
It worked!

Luckily I write to a MemoryStream in my utility, so I just had to get the length and expose the result as a property. Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.