472,328 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 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 15 '05 #1
4 3589
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 15 '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 15 '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 15 '05 #4
"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 15 '05 #5

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...
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...
3
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...
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...
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...
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...
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...
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/"; //...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.