Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Getting the Size of an In-Memory Bitmap

Posted on 2004-11-22
3
Medium Priority
?
213 Views
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.
0
Comment
Question by:boulder_bum
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 12652057
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
 
LVL 8

Author Comment

by:boulder_bum
ID: 12657359
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
 
LVL 8

Author Comment

by:boulder_bum
ID: 12673036
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

571 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