473,388 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Compressing image colors:

I have a aspx page that outputs an image to the response.outputstream. This
works great. However, I want to be able to make the image it outputs a .gif
file. I can change the output type to "image/gif" and save the image by
doing:

myBitmap.Save(response.outputstream,ImageFormat.Gi f)
and this works, BUT it uses a horrible halftone palette to reduce the
colors. I have been trying for a day and a half to figure out any way to
reduce the colors into a .gif with no success. You can see the articles at:
http://support.microsoft.com/default...;EN-US;Q319591 and
http://support.microsoft.com/default...;EN-US;Q319061 which
actually work, but only in grayscale. Does anyone have any ideas of a way to
do this?

OR

I have also tried outputting the file as a PNG, which works, but because
(for whatever reason), the png always comes out darker than the original,
and I need the background color of my image to match the background color on
the site. SOOOooo... If someone can tell me how to make a background color
of a png transparent, programmatically, that might work too.

Thanks for any help!!!
Nov 20 '05 #1
3 1993
Hi MC D,

Strange things happen. Only today I was browsing on a totally different
question and came across this

Color Quantization and GDI+ GIF with much better quality
This sample shows how to decrease colors in an image from 24bit to 8 bit. And
various other numbers of colors as well, from 8 to 256. Quantization is done
by using an octree. Many thanks to vbaccelerator.com.

GDI+ uses a halftone palette by default to save the image to file. This leads
to terrible quality in many cases. This sample greatly improves the saved GIF
image. Enjoy!

http://www.dotnetforums.net/t74693.html
Regards,
Fergus
Nov 20 '05 #2
Thanks! I'll give it a look!

-D

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:O3**************@tk2msftngp13.phx.gbl...
Hi MC D,

Strange things happen. Only today I was browsing on a totally different question and came across this

Color Quantization and GDI+ GIF with much better quality
This sample shows how to decrease colors in an image from 24bit to 8 bit. And various other numbers of colors as well, from 8 to 256. Quantization is done by using an octree. Many thanks to vbaccelerator.com.

GDI+ uses a halftone palette by default to save the image to file. This leads to terrible quality in many cases. This sample greatly improves the saved GIF image. Enjoy!

http://www.dotnetforums.net/t74693.html
Regards,
Fergus

Nov 20 '05 #3
"MC D" <as***@earthtalk.com> wrote in message news:<uX**************@TK2MSFTNGP11.phx.gbl>...
I have a aspx page that outputs an image to the response.outputstream. This
works great. However, I want to be able to make the image it outputs a .gif
file. I can change the output type to "image/gif" and save the image by
doing:

myBitmap.Save(response.outputstream,ImageFormat.Gi f)
and this works, BUT it uses a horrible halftone palette to reduce the
colors. I have been trying for a day and a half to figure out any way to
reduce the colors into a .gif with no success. You can see the articles at:
http://support.microsoft.com/default...;EN-US;Q319591 and
http://support.microsoft.com/default...;EN-US;Q319061 which
actually work, but only in grayscale. Does anyone have any ideas of a way to
do this?

OR

I have also tried outputting the file as a PNG, which works, but because
(for whatever reason), the png always comes out darker than the original,
and I need the background color of my image to match the background color on
the site. SOOOooo... If someone can tell me how to make a background color
of a png transparent, programmatically, that might work too.

Thanks for any help!!!


If you are using MSIE to view the images, they appear darker because
MSIE mishandles the gamma data. Try removing the gAMA chunk and
using only the sRGB chunk, and see if the color level is better.
You can use the pngcrush application from an MSDOS window to do this.

pngcrush -rem gama -srgb 1 in.png temp.png

Get pngcrush from the DOWNLOAD link at http://pmt.sf.net/pngcrush

Glenn
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? ...
3
by: Mr. x | last post by:
Hello, I would like that my image's background color will be transparent. What I have is only paintbrush. My image is *.jpg format (I have tried to save it as *.gif format, and I got less...
4
by: MC D | last post by:
I have a aspx page that outputs an image to the response.outputstream. This works great. However, I want to be able to make the image it outputs a .gif file. I can change the output type to...
0
by: bearophileHUGS | last post by:
Hello, this time I have a question about PIL usage, maybe if Lundh has some time he can answer me. I am experimenting different color quantization algorithms, so having computed the palette with a...
4
by: Jmc | last post by:
Hi Need some advice on how to get all colors in an image. I wish to have an input file, in my case it will be a scanned piece of fabric. I would like to first of all gen an array with all the...
1
by: jitu78 | last post by:
GIF Images Use GIF files for images that have a small number of colors. GIF files are always reduced to no more than 256 unique colors. The compression algorithm for GIF files is less complex than...
7
by: Cate Archer | last post by:
I want to have a border around an image that changes color when the mouse hovers over it. The following code works perfectly in FireFox but not in Internet Exploiter. The text link changes color...
1
by: oruccim | last post by:
hi I want understanding pictures colorfull for examle colorfull or black-white image.google.com there are understand it .Can I understand it thanks....
7
by: mishrarajesh44 | last post by:
hii all Truly telling i hav got this code from net & i am finding error while running the code below.. code:- <?php $idir = "photo/"; // Path To Images Directory $tdir =...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.