Getting the Size of an In-Memory Bitmap

Posted on 2004-11-22
Last Modified: 2010-04-15
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.
Question by:boulder_bum
    LVL 48

    Accepted Solution

    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.
    LVL 8

    Author Comment

    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.
    LVL 8

    Author Comment

    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!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now