Bitmap Compression
page 1 of 1
Published: 25 Mar 2004
Unedited - Community Contributed
Abstract
By default the JPEG files that GDI+ outputs can sometimes look a little crummy. This is because they are not output at the highest possible quality. While this can be frustrating if outputting something that requires clean lines, such as text, you rarely notice much with photographs. But what about if you need your picture to look crisp but can not use an alternative format such as GIF or PNG?
by Chris Garrett
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 24859/ 49

Bitmap Compression

 

What if you really need a crisp JPG image?  Luckily GDI+ has hidden in it's ample folds a facility to allow you to set the quality of your JPG output and (thankfully) it is a really simple thing to do.

 

low quality

/chrisg/tools/compression.aspx?comp=0

 

highest

/chrisg/tools/compression.aspx?comp=100

 

view source (c#)

/chrisg/tools/view-compression.aspx.aspx

 

download source (c#)

/chrisg/tools/download.asp?file=compression.aspx

 

download source (vb)

/chrisg/tools/download.asp?file=compression-vb.aspx


User Comments

Title: Compression   
Name: Jacky
Date: 2009-02-05 7:53:00 AM
Comment:
THANKS A TON for you'r vb code!!!!!!
It works great!!!!!!
Title: PNG Compression   
Name: Mark
Date: 2006-06-04 10:18:46 PM
Comment:
What about compression for PNG files? The new web standard will be PNG and not JPG soon, and I need to compress my generated png images before saving them to my web server. Right now, my 180x100 product images are being saved at 50kb each, and I show 12 product images per page, so thats a total of 600kb! I need compression for PNG please!

I tried just changing the code from:

If (arrayICI(x).FormatDescription.Equals("JPEG")) Then

to

If (arrayICI(x).FormatDescription.Equals("PNG")) Then

but that doesn't help.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-08-23 1:42:19 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search