Brendan Tompkins

Sponsors

The Lounge

Wicked Cool Jobs

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Use GDI+ to Save Crystal-Clear GIF Images with .NET

In an effort to make our gate camera images visible on a ridiculously small cellphone screen,  I spent the past couple of days learning about the process of image Quantization.   GDI+ will allow you to take a full-color 32 bpp image and save it as a .gif file!  This turns out to be quite simple, and you can even re-size the image before saving it, by using the CreateThumnailImage method.

System.Drawing.Bitmap b = new System.Drawing.Bitmap(“c:\\original_image.gif“);
System.Drawing.Image thmbnail = b.GetThumbnailImage(100,75,
null,new IntPtr());
thmbnail.Save(“c:\\thumnail.gif“, System.Drawing.Imaging.ImageFormat.Gif);

“Cool!“ You're thinking to yourself, but don't think too soon.  You may be less-than-impressed by the dithery, grainy image produced by this technique.  Here's the output of this method with one of our gate camera images: 

So, what accounts for the grainy image?  It has to do with color quantization, sometimes called “palettization” or simply, the process of slapping a 256 color palette onto a full-color image, thereby reducing the total colors (and file-size).  The image is grainy because GDI+ by default uses the windows 256-color palette, and doesn't take into account the colors in the actual image.  When I found this out I went in search of a better color quantization technique for saving .GIF images... 

Personally I've found that almost all GIF images should be saved with an adaptive palette. These days, forget about the Web Palette, unless you're doing icons or big areas of solid color.  Most everyone will be running in at least 16K colors, and if by some small chance they're still running 256 colors, the browser will dither an adaptive image to a reasonable version anyhow.  An adaptive palette contains the 256 most frequently used colors in the image. Well, um sort of anyway. (As an aside, I tried to write my own “popularity palette” algorithm which used the most frequently used colors to build the palette, but my images looked worse than before!)  A good quantization algorithm also takes into account spacing between colors and stores colors that are, say blue and very-nearly-blue as one color, freeing up more space for colors that the eye sees as separate.  One such adaptive palette algorithm is called the “Octree“ algorithm.

I found two articles from Microsoft that helped out a great deal, KB 319061  and Optimizing Color Quantization for ASP.NET Images by Morgan Skinner at MS.  Morgan's article had some great code samples, and really useful base class which will allow you to plug in your own algorithm to quantize images. I ended up pulling bits and pieces of code from the two articles to create a library of objects used for creating Octree and Grayscale palettes.  Using the OctreeQuantizer object was easy, as you can see in this code snippet:

System.Drawing.Bitmap b = new System.Drawing.Bitmap(“c:\\original_image.gif“);
System.Drawing.Image thmbnail = b.GetThumbnailImage(100,75,
null,new IntPtr());
OctreeQuantizer quantizer =
new OctreeQuantizer ( 255 , 8 ) ;
using ( Bitmap quantized = quantizer.Quantize ( thmbnail ) )
{
     quantized.Save(“c:\\thumnail.gif“, System.Drawing.Imaging.ImageFormat.Gif);
}

OctreeQuantizer grayquantizer = new GrayscaleQuantizer ( ) ;
using ( Bitmap quantized = grayquantizer.Quantize ( thmbnail ) )
{
     quantized.Save(“c:\\thumnail.gif“, System.Drawing.Imaging.ImageFormat.Gif);
}

This code produced the following beautiful (In this case, beauty truly is in the eye of the guy who just spent three days trying to get it to work!) thumbnails, one with an adaptive palette, and one in grayscale. 

If you've got a cellphone with web capabilities, go to http://mobile.vit.org/ and see the image in all its 100 X 75 pixel glory.

UPDATE: 

See this post here for the latest version of this library

 

-Brendan

 


Posted Mon, Jan 26 2004 1:17 AM by Brendan Tompkins

[Advertisement]

Comments

Paul Calderon wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Feb 11 2004 9:47 AM
I have problems with your code, with the dependencies of sistem.drawing

Can you help me please
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Feb 12 2004 4:01 AM
Not sure Paul. Are you opening my sln file directly?
Chrei Verdend wrote Using color quantization project in VB aspx page
on Mon, Mar 8 2004 6:45 AM
Please be patient - this is all new to me.

I am trying to create an aspx page, written in VB, that receives text from a form's input box, then generates a gif of the text and saves it to file. Everything is working fine except that the default halftone palette is terrible. I understand that the GIF needs to be color quantized to make it look decent and I believe that is exactly what your code does.

Problem is, I downloaded your project and have absolutely NO IDEA how to implement it into my apsx page. Your instructions say to "change the namespace and you've got your own adaptive image quantizer." Can you please explain how to do that, or point me in the right direction?

Also, is it going to be a problem that my aspx page is written in VB? If so, do I need to convert my code to C# to run your script? (I have no idea how to do that, but I could try.)

Otherwise, do you have any other suggestions for how I might get this accomplished?

Thanks for any and all help!!

Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Mar 8 2004 7:18 AM
Chrei... No problem. You can certainly use my assembly from VB.NET. That's the beauty of .NET IL! I built the dll for you, here's the download, with the PDB debug info too:

http://www.intrinsigo.com/bsblog/ImageQuantizationDll.zip

Drop this dll into your site's bin directory, and add a project reference to the DLL. You should then be able to create an instance of the ImageQuantizer from your aspx vb code, and call its Quantize method.

-Brendan
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Mar 8 2004 7:20 AM
Sorry Chrei, you need to create an instance of the PaletteQuantizer object
Cheri Verdend (yes, I mistyped my name before) wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Mar 8 2004 9:49 AM
Hi Brendan,

Thank you for responding so quickly! I'm trying to do what you told me to do... but I'm still a bit lost. (This is my first experience with .cs files, and I'm doing this in a text editor, not VS).

I've created an IIS virtual directory, in which I have a directory named "bin" (I hope that is all I need to do to create a bin directoy). In the bin directory I have saved the "ImageQuantization.dll" and the "ImageQuantization.pdb" files. I also saved my aspx file and all the files from your ImageQuantization.zip into the root of my virtual directory.

Below is the code for my aspx file. Right now it creates and saves a GIF with ugly colors. Would you please tell me exactly what code to insert and where to insert it to: add a project reference to the DLL and to create an instance of the PaletteQuantizer object.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aspx code starts here
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Drawing"%>
<%@ Import Namespace="System.Drawing.Text"%>
<%@ Import Namespace="System.Drawing.Imaging"%>
<%@ Import Namespace="System.Drawing.Drawing2D"%>

<script language="VB" runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
If Request("StringToDisplay")<>"" then
'Create the bitmap
Response.Clear( )
Dim objBitmap As New Bitmap(180,30, pixelformat.Format32bppArgb)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
objGraphic.Clear(Color.FromArgb(0, 255, 255, 255))
objGraphic.SmoothingMode = SmoothingMode.AntiAlias
objGraphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
Dim textBrush As New SolidBrush(Color.FromArgb(255, 51, 0, 102))
Dim bgBrush As New SolidBrush(Color.white)
objGraphic.FillRectangle(bgBrush, 0, 0, 180, 30)
Dim objPoint As New PointF(0,0)
Dim objFont As New Font("Arial", 11, FontStyle.Bold)
objGraphic.DrawString(Request("StringToDisplay"), objFont, textBrush, objPoint)
'Save the image to file
objBitmap.Save(server.mappath("Image.gif"), System.Drawing.Imaging.ImageFormat.Gif)
objGraphic.Dispose( )
objBitmap.Dispose( )
End if
End Sub
</script>

<html><head><title>Text creation test</title></head><body><BR><BR>
<form method="POST" action="test.aspx">
String to write: <input type="text" name="StringToDisplay">
<input type="submit" value="Submit Text">
</form>
</BODY></html>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After several days of searching and searching for a solution, I feel like I'm very close. You are a life-saver. Thank you, again, for your help!

Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Mar 9 2004 12:55 AM
As to where to add this code... Try replacing this line of code from your original source with the above code:

objBitmap.Save(server.mappath("Image.gif"), System.Drawing.Imaging.ImageFormat.Gif)
Cheri Verdend wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Mar 9 2004 11:30 AM
Brendan,

Ah! I finally got it working. Something was wrong with my .NET installation. Even though the dll was in the bin directory, I continued to get errors that that the namespace could not be found. After a myriad of false starts I finally uninstalled and reinstalled .NET - and now it works perfectly!

Thank you so much for your help!
Gary Peluso wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Mar 11 2004 10:27 AM
Is there a way to set the transparent color? It defaults to black, but I need it to be white.

Thanks
Homam wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Mar 29 2004 6:20 AM
Thanks! It's very useful.
Is there any way for quantization Jpeg images? I mean how can i save a jpeg image in a differrent quality?
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Mar 29 2004 6:24 AM
Right. JPEG images aren't quantized, because each pixel's color value is mathematically determined, not taken from a palette. There's got to be a way to set the level of compression, which relates to image quality. Not sure how to do this, however...
Groves wrote Much Appreciated
on Wed, Mar 31 2004 11:31 AM
Just wanted to thank you for your hard work. That library works like a charm -- I was having trouble with the standard ImageFormat.GIF exporting transparent, but yours works great.

Oh, and to Gary who'd asked about the transparency. If you haven't found it yet, try <b>MyImage.MakeTransparent(Color.White)</b>

Thanks, again,
Groves
Fred Thieme wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Apr 8 2004 10:15 AM
Brendan

Thanks for the very useful color reduction code/dll. I came across your work while doing research for a pet project of mine. I was just gearing to do what you have already done I even read the same MSDN article that you site in your intro. I had your dll working in a VB test project in about 5 min. One Question -- Have you made any improvements or fixed any Bugs since posting the code and dll that I downloaded today 4/8/2004. Thanks again.

Fred
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Apr 8 2004 12:39 PM
Fred,

What's out there is the latest. I'm not aware of any glaring bugs. I have the dll in production on a server and it seems to be chugging along.

-B
Fred Thieme wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Apr 9 2004 4:44 AM
Great -- thanks for responding. I will plug it in and see how it goes.
Fred Thieme wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Apr 9 2004 10:11 AM
Brendon:
Here is a method to set the transparent color for the gif file. First your dll optimizes the palette. Then before saving the file call the SetTransparentColor method on the optimized palette. The .NET Gif encoder will use the slightly modified palette to actually set the transparent color in the file. None of the color values are actually changed just the Alpha values. Check it out -- it works.

Private Sub ConvertToGif()
''load image to convert
Dim BMPQuantized As Bitmap
Dim BMPSource As Drawing.Image = Image.FromFile("C:\Ant.bmp")

''optimize the palette
Dim quantizer As New OctreeQuantizer(255, 8)
BMPQuantized = quantizer.Quantize(BMPSource)

''set the transpatent color where Color.Black is the desired transparent color
BMPQuantized.Palette = SetTransparentColor(BMPQuantized.Palette, 255, Color.Black)

''save as new .gif
BMPQuantized.Save("C:\AntConverted.gif", System.Drawing.Imaging.ImageFormat.Gif)
MsgBox("end")
End Sub

Private Function SetTransparentColor(ByRef SrcPal As ColorPalette, ByVal nColors As Integer, ByVal cT As Drawing.Color) As ColorPalette
''set the trans color in SrcPal
Dim i As Integer
Dim C As Drawing.Color
Dim Clrs() As Drawing.Color = SrcPal.Entries
For i = 0 To nColors
C = Clrs(i)
If (C.R = cT.R) And (C.G = cT.G) And (C.B = cT.B) Then ''match
SrcPal.Entries(i) = Color.FromArgb(0, C.R, C.G, C.B) ''trans
Else
SrcPal.Entries(i) = Color.FromArgb(255, C.R, C.G, C.B) ''opaic
End If
Next i
Return SrcPal
End Function


Tommaso wrote cool... but how reduce color depth ?
on Fri, Apr 16 2004 3:22 AM
And if i want a optimized color reduced gif ?
Tommaso wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Apr 16 2004 3:26 AM
eS: 16 color...
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Apr 16 2004 3:30 AM
Well, I haven't poked around in the code in a while, but I think it's just a matter of overloading a method to pass in the bit depth you are looking for...
Herb wrote Very cool! Thanks so much
on Tue, Apr 27 2004 11:30 AM
Brendan - Great work. Just came across your article while trying to fix this problem in outputting gifs, downloaded your dll, and five minutes later my gifs look beautiful. Thanks so much for your contribution.
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Apr 28 2004 3:32 AM
Herb... Glad to have helped!

Brendan
Daniel wrote You saved me three days of work - you're a great guy!
on Thu, Apr 29 2004 12:51 AM
This class worked perfectly for me. I have a few classes that I always keep nearby because they are so damn good: ImageQuantizer is now one of them.

Thank you thank you thank you thank you ...
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Apr 29 2004 2:05 AM
Glad to have helped Daniel. Good luck!

B
Linus Betschart wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, May 11 2004 12:38 AM
Hello

is it possible to save BMP Bitmaps with this class in 16 to 256 colours? With .net itself it's as I know not possible to save in different colour formats...

thx
LB
Jerry Spaeder wrote Awesome!
on Mon, May 17 2004 7:42 AM
I downloaded the DLL you created for Cheri Verdend. Works great!

Thanks,
Jerry
Christoph Pecher wrote Ad Dithering?
on Thu, Jun 3 2004 6:07 AM
The quantization algorithm is not enough. I have problems with areas slowly changing color(gradients). I found an article concerning that issue, but no code that i cound translate to c-sharp. Anyone knows about how to implement the Error Diffusion Dithing in the second pass of the octree quantization? http://www.leptonica.com/applications.html#COLOR-QUANTIZATION
NatoCM wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Jun 9 2004 5:55 AM
Brendan, thank you so much for your code. It worked just fine! Regards from Brazil!
Andrew wrote Yep - well done!
on Thu, Jun 24 2004 3:09 PM
Great code, saved me from trying to do the same thing myself and wasting hours of time!
Thanks!
Avalon wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Jul 18 2004 3:08 AM
Briliant.... there i was trying to work out a formual to correct the darkening of Png images in IE when i came across this little wonder code :) Life saver, Still need to fixteh png problem sometime though, Also does you code work with png transparency too... i ahve yet to test it.
darrel wrote thank you, thank you, thank you
on Tue, Jul 20 2004 4:41 AM
THANK YOU! I spent the last couple of days searching for a way to fix the GIF saving problems. I finally stumbled across the Quantizer article on MSDN but that was a tad over my head to get working. That finally led your DLL which couldn't have been easier!

I'm rather amazed that the default GIF behaviour in .net is based on the windows pallet, but, then again, maybe it's not that surprising. ;o)

As for the person with the JPG question, you need to set the codec compression rate. Here's what I'm using (VB.NET):

====================

myImageCodecInfo = GetEncoderInfo("image/jpeg")
Dim myEncoderParameters As EncoderParameters = New EncoderParameters(1)
' this line sets the JPG compression quality
'(100 = best quality, 0 = most compression)
Dim myEncoderParameter As EncoderParameter = New EncoderParameter(myEncoder, 90)
myEncoderParameters.Param(0) = myEncoderParameter
imgOutput.Save([your path], myImageCodecInfo, myEncoderParameters)
imgOutput.Dispose()

========================
James wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Sep 5 2004 3:58 PM
Brendan,
Lovely little library - thanks very much for posting this.

What is the difference between the PalleteQuantizer and the OctetQuantizer?
Ry wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Sep 23 2004 8:05 AM
Quick and easy for me to use. Thanks for putting this out there for us!!!
Ian Kevan wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Oct 27 2004 3:09 AM
Hi Brendan,

Thanks for the quantization code. I have the same problem as one of your other users in that when applying the Octree quantization to a captured windows XP form, because of the complex gradients in the title bar and toolbar, you end up with a very blocky looking graphic. Have you had any joy determining a way or applying error diffussion to the Octree quantization method?
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Oct 27 2004 3:18 AM
Hi Ian,

I'm sorry to say that I haven't delved into other quantization methods since I first worked with this code. You should be able to plug a different quantizer in, however, if you find the algorithm out there somewhere.

Good luck.

Brendan
Ian Kevan wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Oct 27 2004 10:51 PM
Tnaks Brendan, I will continue my search.
Ross Presser wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 9 2004 8:28 AM
Hi Brendan,

I've been working with you quantization code, and I have hit a most confusing problem.

On many images it works perfectly; but on this image, I am getting this exception:

Unhandled Exception: System.ArgumentException: '-169' is not a valid value for 'red'. 'red' should be greater than or equal to 0 and
less than or equal to 255.
at System.Drawing.Color.CheckByte(Int32 value, String name)
at System.Drawing.Color.FromArgb(Int32 alpha, Int32 red, Int32 green, Int32 blue)
at System.Drawing.Color.FromArgb(Int32 red, Int32 green, Int32 blue)
at ImageQuantization.OctreeNode.ConstructPalette(ArrayList palette, Int32& paletteIndex) in C:\Documents and Settings\btompkins\Desktop\ImageQuantization\OctreeQuantizer.cs:line 454

It's almost as if there is so much red in this image that the _red member (which was declared as an int) went negative?

I'll try isolating and maybe fixing this, but I'm not good with C#... I'll let you know what if anything I discover.
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 9 2004 8:32 AM
Man, that's strange. Looks like possibly the image is corrupt, and it's trying to read image data where it can't find any?
Ross Presser wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 9 2004 8:47 AM
I was right. Recompiling with /check+ and running my test case caused it to throw an arithmetic overflow exception in OctreeNode.Increment. I changed the definitions of _red, _green, _blue and _pixelcount from "int" to "ulong", and made this change to compensate, in OctreeNode.ConstructPalette:

// And set the color of the palette entry
palette.Add ( Color.FromArgb ( (int)(_red / _pixelCount) , (int)(_green / _pixelCount) , (int)(_blue / _pixelCount) ) ) ;

Now it works on all my images.

Thanks again for the code!
Ross Presser wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 9 2004 8:49 AM
Maybe this never cropped up before because I was just using larger images than you're used to. My images are 1500x1650 pixels; they're geographical maps that we put into trip routing books that you get from your auto club.
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 9 2004 8:50 AM
Ah... Cool. Can you send me the code that you updated, so that I can post it?

Thanks!
Ross Presser wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 9 2004 9:15 AM
Can't find an email address for you ... grab it at http: // www.imtek.com /images/updatedcode.zip [remove spaces to fix the deliberately broken link I typed]
Anthony Ruggeri wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 16 2004 2:47 AM
Great work on this library, it saved me a ton of time adapting an automatic graphics generator from using PNGs to GIFs due to a color interpretation bug in IE6. Let me know if you take any payments or contributions!
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 16 2004 2:51 AM
Nope. Thanks is plenty!
Ross Presser wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 23 2004 2:18 AM
Did you ever grab my updated code? If not, could you email your email address to me at rpresser AT imtek DOT com so I can mail it to you?
Pasquale Alfonso (aka)Bklynjava wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Dec 8 2004 3:23 PM
Nice work, although I have numerous errors opening with C#.

Any advice is appreciated.
Hugo wrote Amazing!
on Thu, Dec 9 2004 5:16 AM
Thanks and thanks again! I've been trying to find something like this for days!
Murray wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Dec 13 2004 3:27 PM
Cool
But what if my hosting environment doesn't like unsafe code? is there a safe version?
I realise it may be slower, but it only runs infrequently as a batch job.

Cheers.
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Dec 14 2004 1:08 AM
Murray, the unsafe is there so that we can pass a pointer to the quantizer ie (Color32* pixel) I'm not sure how to rework this in managed code without looking and getting into the details. You could try passing the Color32 by ref, and see where you get.

-Brendan
brendan - you're a star wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Dec 20 2004 11:22 PM
thanks mate, just what i needed...and better than i was looking for.
Chris Lewis wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Jan 11 2005 1:30 AM
...have been searching for some time for what you've done here - thanks a lot.
Doug Weems wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Feb 17 2005 6:09 AM
Thanks Brendan,

This was very helpful. You are one of the good guys. :-)
John Hamm wrote 4-bit images
on Fri, Mar 4 2005 12:58 AM
I have modified the Quantizer class in that I can now pass the Quantize method a PixelFormt parameter so I can produce 4-bit images.

The problem, though, is that I think there is something odd going on in the OctreeQuantizer class - the bitmap that is produced has every other vertical row blank, and that widens the image, and cuts off half the image.

I think the problem may lie somewhere in FirstPass and SecondPass methods, I don't know enough about it to be sure though. Is traversing the pixels the same in a 4-bit image in memory as it is an 8-bit image?

Any ideas?
John Hamm wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Mar 4 2005 12:59 AM
I meant to say "every other vertical column"
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Mar 4 2005 6:06 AM
John,

Which Quantizer did you modify? The correct way to do this would have been to create a new class deriving from Quantizer called FourBitQuantizer or something, and then modify the QuantizePixel and InitialQuantizePixel methods.

I'm not surprized that it cut the image in half and only rendered every other line. Everything was based on 8 and you substitued 4!
Daniel wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Mar 19 2005 3:17 AM
Is there a smart way to crop a created image, to eliminate all the space surrounding the rendered text?

"objGraphic.MeasureString(sText, objFont).Width" usually adds a lot of space, especially when using large font sizes. That extra margin causes rendered headlines to not line up well with body text.
.NET Tools Blog wrote DynamicImage
on Wed, Mar 30 2005 11:57 AM
Bill Oscott wrote Access ImageQuantization.dll from VB6
on Mon, Apr 11 2005 1:40 PM
Hi

This dll is cool, I had program running in VB.net that accessed its functions in 5mins. Thing is I would also like to use VB6 to access the dll. Is there anything I can do??

Thanks

Bill
Hubris Sonic wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Apr 28 2005 4:13 AM
niiiiiiiiiiiiiiiice dude!
Max wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, May 3 2005 2:19 PM
Well done! I had little-to-no trouble implementing this into my system.

(What I want to know is why the current version of .NET doesn't already support this properly -- this seems like a common thing to do with graphics!)
Peter M wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, May 12 2005 9:08 AM
First of all, thanks very much for your efforts. This code was exactly what I've been looking for. :)

I'm using it to return gif images through the Response.OutputStream of an aspx page. The weird thing is that the transparency is working fine with some images and not with others although they all come from the same source.

Any thoughts would be greatly appreciated.
Ganesha wrote Thanks for the dll
on Tue, May 24 2005 11:27 PM
Thank you for the dll, my map image looks better now. Best regards from Jakarta.
Yukiko wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Jun 6 2005 6:57 PM
I still not quite understand the whole thing and how to use it after downloading? Can someone please help me?
Dave wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Jun 7 2005 3:54 AM
This is awesome. Just about to try to write my own version, found this site, five minutes later I have crystal clear images.

Thank you.
phil wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Jul 19 2005 3:51 PM
Using Quantizer to reduce size of bitmap when saved to file. Works perfectly. Thanks.
srounsroun wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Aug 18 2005 5:55 AM
Hi,

I'm working on gif files, the link for the dll doesn't work. Can someone could send me thte .zip file in my hotmail box ? thanks a lot, Hope this will resolve my optimization problem :)

here my hotmail box: srounsroun@msn.com

thanks

srounsroun wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Aug 18 2005 6:54 AM
lol, sorry I found it on the zip file up there

check in bin/debug to get the DLL.


by all and thanks a lot
Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Aug 18 2005 3:54 PM
Bill wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Oct 1 2005 10:12 AM
I've been working on my site to generate Hebrew characters and though I could force someone to download a font to view them, I wanted to dynamically generate the images. You're DLL is the best and got rid of those pesky "white" dots around the characters. Do you have the code in VB? Thanks,

Bill
Brendan Tompkins wrote How to Get your Projects Noticed by Microsoft
on Thu, Feb 23 2006 10:47 AM
I got the exciting news this week that a case study for one of the projects I've been working on has...
Brendan Tompkins wrote How to Get your Projects Noticed by Microsoft
on Thu, Feb 23 2006 10:51 AM
I got the exciting news this week that a case study for one of the projects I've been working on has...
Brendan Tompkins wrote How to Get your Projects Noticed by Microsoft
on Thu, Feb 23 2006 11:21 AM
I got the exciting news this week that a case study for one of the projects I've been working on has...
Brendan Tompkins wrote How to Get your Projects Noticed by Microsoft
on Thu, Feb 23 2006 11:32 AM
I got the exciting news this week that a case study for one of the projects I've been working on has...
Lee wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Apr 2 2006 11:22 PM
Tried the original dll as well as this dll, all works beautifully on my machine locally, when I uploaded to my hosting, permission deneid. I'm guess the Quantizier is referencing system managed classes.. darn. what a shame.

really really loved this class.
Sebastian Krampe wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Apr 3 2006 5:56 AM
Thanks for the classes, Brendan. They work great!

And Fred: Thanks to you for the transparent palette method.
Here's the version in c#:

ColorPalette SetTransparentColor(ColorPalette SrcPal, int nColors, System.Drawing.Color cT)
{
System.Drawing.Color C;
System.Drawing.Color[] Clrs = SrcPal.Entries;
for (int i = 0; i < nColors; i++)
{
C = ClrsIdea [I];
if (C.R == cT.R && C.G == cT.G && C.B == cT.B)
{
SrcPal.EntriesIdea [I] = Color.FromArgb(0, C.R, C.G, C.B);
}
else
{
SrcPal.EntriesIdea [I] = Color.FromArgb(255, C.R, C.G, C.B);
}
}
return SrcPal;
}

Regards
Sebastian
xuefeng yu wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Apr 6 2006 11:02 PM
this is gread work!!!
thanks
Jimbob wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, May 23 2006 11:52 AM
Great stuff mate. I would have expected this to be part of GDI+ to be honest, as MS have done such a good job with the rest of it.

Thanks again.
Chris K wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, May 23 2006 2:35 PM
Hello, this stuff is awesome. Fortunatly I found this page, when this problem occured in my program.

What i wanted to ask: Is there any solution to save partly transparent (Opacity: 50%, or something like this) areas? pixels with alpha=255 are saved transparent, but when the alpha value is less then 255, these pixel are black!

Chris
Steve wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Jun 9 2006 4:14 AM
Hello,

I really would like to be able to use you code but Im not sure if I can. So far I have an image being displayed using a .ashx file. This file basicaly gets an jpeg image from a database and makes it into a trnasparent gif but obviously the gif looks terrible.

Can I use your code? And if so how? I've never used a .dll file like this before.

Thanks in advance,
Steve
Will wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Sep 25 2006 6:30 AM

Thanks a million.

Like many others here, I was reluctantly bracing myself to do battle with the MSDN code and you've saved me ages.

Ariel wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Oct 8 2006 8:49 PM

Hi brendan, i congratulate you for your project.. i'm trying to use it but i can't make it work.. i'm creating dynamic images with text (drawstring with a Graphics), and i'm not sure where to use the quantizer, if i modify the bitmap before the "Graphics graph =Graphics.FromImage(bm)" it throws an exception liek this: "A Graphics object cannot be created from an image that has an indexed pixel format. ", if i put it after then it remains black at the end..

Just in case i post the function i made to create the Graphics:

public Graphics openGraph(ref Bitmap bm,string bgcolor)

{

        if(bgcolor=="Transparent")

        {

OctreeQuantizer quant=new OctreeQuantizer(255,8);

bm=quant.Quantize(bm);

        }

        Graphics graph = Graphics.FromImage(bm);

        graph.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;graph.InterpolationMode=System.Drawing.Drawing2D.InterpolationMode.Bilinear;

        graph.Clear(Color.FromName(bgcolor));

          return graph;

}

(i've already tried this one with it too:

"bm.MakeTransparent(Color.FromName(drpBackcolor.SelectedItem.Text));

bm.Save(......)")

but nothing..plz if someone can answer me, i'd appreciate that thx..(if you can, mail me plz to flesler@hotmail.com)

Ariel wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Oct 11 2006 2:48 PM

I tried doing it at the end of the drawing, just before saving and it improves the quality, but no transparent background.. plz can some1 ask me as soon as possible? I really need it

Ariel wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Oct 11 2006 2:48 PM

I tried doing it at the end of the drawing, just before saving and it improves the quality, but no transparent background.. plz can some1 ask me as soon as possible? I really need it

Sylvain Fasel wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Nov 7 2006 7:56 AM

Hi,

thank you very much for this wonderful piece of code, seeminglessly integrated into my project.

For what I need it to do, it works perfectly, and the images are perfect.

So cool to share this freely!

Best regards.

Shaun Llewelyn wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Nov 9 2006 9:34 AM

Thanks, I was getting grainy gifs. Worked a treat. Brilliant!

Barry wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Dec 4 2006 7:02 PM

Hello.

***I am a newbie who needs help! ***

This looks like the perfect program I would need to convert a 256 color GIF that is located on my web server in a folder called temp, into a 16 color GIF.

After it is converted, I want to save it with the same name and path.

I have Visual Web Developer 2005 Express.

Please help me set this up.

I have no .aspx file yet.

(Also, I have no experience yet).

I will be coming from an asp page that has the filename in the url like my_page.asp?file_name=image_256.gif

I am used to vbscript, so I would get the filename with:

file_name= Request.QueryString("file_name")

I have placed all files (from the download above) in a web folder called gif_16

Any help to figure this out would be appreciated.

Thanks in advance!!!

Barry in Ottawa, CANADA.

Brendan Tompkins wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Dec 5 2006 8:02 AM

Barry,

The quantizer code should produce a 16-color gif using the following command:

OctreeQuantizer quantizer = new OctreeQuantizer ( 15 , 4 ) ;

Barry wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Dec 5 2006 12:35 PM

Hey Brendan. It has been snowing here in CANADA. Looks like it isn't  there!

Thanks for the reply!!

That's great that the code can do it!!

Which lines of code are required to do what I want?

Can you help me set it up?

I see some lines at the top starting with:

System.Drawing.Bitmap b = new System.Drawing.Bitmap(“c:\\original_image.gif“);

I also downloaded your project, do I need it all?

Is there an aspx page missing?

Which files/folders do I need to upload to my web server to get this to work?

I'm a slow newbie.

Please help.

Barry

Brendan Tompkins wrote GIF Image Color Reduction in .NET
on Fri, Dec 8 2006 8:43 AM

A while back, I posed a solution for creating an adaptive GIF image from a JPEG image source in .NET,

Tuan Nguyen wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Dec 15 2006 3:18 PM

can anyone please post the safe managed Code for this?

Anonymous wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Jan 11 2007 10:35 AM

this guy is selling component based on OctreeQuantizer.cs

http://www.amarantin.se/

Manso wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Jan 15 2007 4:16 AM

Hi,

Thanks for an excellent component.

We're trying to use it in a medium trust environment, does anyone have any experience in how to make it work? We are getting "PolicyException: Required permissions cannot be acquired.", can someone provide us with some hints if/how we can make this work?

Many thanks,

Manso

James Maeding wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Jan 18 2007 12:34 PM

Dang, best code I have seen for images with .net so far.

I am killing myself with IMageMagick and other command line progs, and no one seems to make it easy to make good images from 24 bit to 8 bit optimized palette.

This was just what I needed.

James Maeding wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Jan 18 2007 12:59 PM

I just read the previous comments and am wondeeing if the code and dll that we can download, have all the fixes in them?

There was the definitions of _red, _green, _blue and _pixelcount from "int" to "ulong",

as well as the Transparent palette code (bug or feature?...).

Also, I open the code in VS2005 and it gives errors on build. It says:

Unsafe code may only appear if compiling with /unsafe.

I assume I need to add a flag somewhere to fix that, I think the orig code was from VS2003, and VS2005 wants a flag...

thanks

James Maeding wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Jan 18 2007 1:53 PM

ok, had to check the allow unsafe code in build options,

also added suggested changes myself except for transparent option.

If anyone had improved things, please post :)

Allan The Dane wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Jan 18 2007 2:49 PM

Preserving Transparency?

I'm converting a transparent Gif to grayscale using you code. But the transparency seems to be lost during conversion. Is there any way to preserve the transparency in the new image? I'm using the following code, which is basically just a conversion from your C# code to VB:

Dim objBitmap As New Bitmap("Transparent.Gif")

Dim objNewThumb As Drawing.Image = objBitmap.GetThumbnailImage(objBitmap.Width, objBitmap.Height, Nothing, New IntPtr())

Dim objGrayQuantizer As New GrayscaleQuantizer()

With objGrayQuantizer.Quantize(objNewThumb)

  .Save("GrayNoSoTransparent.gif")

End With

Any advice would be appreciated.

BTW - Great work! :)

Allan From Denmark

Justin Wignall wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Jan 19 2007 8:08 AM

Three years later and still really useful! Great stuff Brendan, Thanks!

James Maeding wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Jan 19 2007 2:02 PM

there was code to modify the palette posted by Fred Thieme, see previous posts.

I am currently figuring out how to plug that into things, I am a bit new at the .net objects.  I'll post it when I figure it out.

RS wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Feb 13 2007 8:31 AM

So, how do I make this work:

1. Include the dll (tried both the pre-built version and my own version) in my own web-project.

2. Build error: Failed to grant minimum permission requests.

But I can't even find where to set permissions (in the project, or IIS, or?) ?

Thanks!

RS

Pablo wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Feb 14 2007 5:36 AM

Eres el puto amo!

You're the master, you saved us many hours.

Thanks from Spain!

清清月儿 wrote 在.net中使用GDI 来提高gif图片的保存画质
on Wed, Mar 21 2007 11:33 AM

在.net中使用GDI 来提高gif图片的保存画质

ca1 wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Mar 23 2007 4:44 PM

Thank you!

Andrey wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Mar 23 2007 5:43 PM

The best! Thank you very much for this!

Matt Eason wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Apr 18 2007 10:51 AM

Fantastic stuff. Dropped it into my project and it worked first time, no problems. Thanks!

Marco wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Apr 28 2007 1:50 PM

GIF TRANSPARENCY... ANOTHER SOLUTION:

First of all, thanks for this great work!

Second, I've found a solution for preserving GIF transparency when invoking Image::Save(...). The .NET (tested on v2.0) GIF encoder considers transparent the first color found in the palette, so I've changed some methods (replace them with the supplied ones):

// METHOD: OctreeQuantizer::QuantizePixel(Color32* pixel)

protected override byte QuantizePixel(Color32* pixel)

{

byte paletteIndex = (byte)0; // The color at [0] is set to transparent

// Get the palette index if this non-transparent

if(pixel->Alpha > 0)

paletteIndex = (byte)(_octree.GetPaletteIndex(pixel) + 1);

return paletteIndex;

}

// METHOD: OctreeQuantizer::GetPalette(ColorPalette original)

protected override ColorPalette GetPalette(ColorPalette original)

{

// First off convert the octree to _maxColors colors

ArrayList palette = _octree.Palletize(_maxColors - 1);

// Add the transparent color

palette.Insert(0, Color.FromArgb(0, 0, 0, 0));

// Then convert the palette based on those colors

for(int index = 0; index < palette.Count; index++)

original.Entries[index] = (Color)palette[index];

return original;

}

// CONSTRUCTOR: GrayscaleQuantizer::GrayscaleQuantizer()

public GrayscaleQuantizer()

: base(new ArrayList())

{

_colors = new Color[256];

int nColors = 256;

// Initialize a new color table with entries that are determined

// by some optimal palette-finding algorithm; for demonstration

// purposes, use a grayscale.

for(uint i = 0; i < nColors; i++)

{

uint Alpha = (uint)((i == 0) ? 0x00 : 0xFF);                    // Colors are opaque (except the first).

uint Intensity = Convert.ToUInt32(i * 0xFF / (nColors - 1));    // Even distribution.

// The GIF encoder makes the first entry in the palette

// that has a ZERO alpha the transparent color in the GIF.

// Pick the first one arbitrarily, for demonstration purposes.

// Create a gray scale for demonstration purposes.

// Otherwise, use your favorite color reduction algorithm

// and an optimum palette for that algorithm generated here.

// For example, a color histogram, or a median cut palette.

_colorsIdea = Color.FromArgb((int)Alpha,

(int)Intensity,

(int)Intensity,

(int)Intensity);

}

}

Andrew wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Jun 8 2007 1:38 AM

I'm also having a permissions error in a medium trust environment (shared server hosting environment).

Can't we have a fix for this please? It's such a great library! Best there is out there, just this one little problem preventing it from being more widely used. :(

liz wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Jun 15 2007 10:41 AM

everytime i go to save a picture it always saves under " bmp " and not " gif " so the picture doesn't move when it's suppose to !!

Tim Down wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Jul 16 2007 5:58 AM

Just wanted to add my own thanks to the many who have posted theirs. This is absolutely perfect for what I need - it's fixed both my problems, namely that I was jumping through hoops to get transparency and that the default colour palette was making my images look terrible. So, many thanks.

Maureen wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Aug 18 2007 1:23 AM

I think I love you!  This worked perfectly -- now my gif's are beautiful and I can remove the annoying disclaimer that "this preview image is grainy but your final product will be lovely".

kral oyunlar wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Sep 13 2007 1:16 PM

Thank you!.

Roy Thomas wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Oct 3 2007 5:49 AM

Can anybody advise  vb or vc code to refresh a real time (Gif file)  from a website and archive it in the local machine every one minute,    Can it be done using using Microsoft web browser control?

please email to    roy.thomas@cegelec.com.sg

thanks

Andy wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Dec 6 2007 4:56 PM

I have tried to implement some of the suggested transparent gif solutions but did not get any of them to work

I can use the one described by microsft at

support.microsoft.com/.../319061

But this is not giving me the results I was hoping for...   Does anyone know how to flatter non transparent pixels that still have an alpha value to a matte color and then cut the rest of the out?  Sort of like Photoshop's saving of a gif?

brendan Do you have version that works with transparencies?

Gretchen wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Fri, Dec 7 2007 10:25 AM

Thank you so much for sharing your wonderful work with 'us'. My charts are now perfect!

hugo oyunlari wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Dec 22 2007 7:01 AM

l love dhis blog it is very nice

barbie oyulari wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Dec 22 2007 7:02 AM

yes it is

AR wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Dec 25 2007 9:25 PM

this is great stuff, however i am facing an issue, can someone help. I am using this quantizer to save a bitmap image into a gif format (so that i donot loose the quality and the image is small), however for images with some specific colors it gives weird results, like for example if the color is Red, half of the image is good and the second half turns black. It also happens with some other colors like Cyan, Blue etc. Has someone faced this issue, can you guys point me in some direction to debug this.

Rüya Tabirleri wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Dec 29 2007 12:40 PM

what is the problem?

what is this posts? spam?

why dont you delete it?

Greg wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Dec 30 2007 11:27 PM

Tried the assembly (downloaded latest dll). Works fine on a local box. But on shared server end up with the error on:

Dim quantizer As OctreeQuantizer = New OctreeQuantizer(255, 4)

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Using in ASP.NET.

mersin wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Jan 5 2008 3:18 PM

thaks

mersin wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sat, Jan 5 2008 3:19 PM

Dim quantizer As OctreeQuantizer = New OctreeQuantizer(255, 4)

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

kral oyun wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Jan 6 2008 11:10 AM

Great code, saved me from trying to do the same thing myself and wasting hours of time!

Thanks!

kral oyun wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Jan 6 2008 11:11 AM

Great code, saved me from trying to do the same thing myself and wasting hours of time!

Thanks!....

youtube wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Jan 7 2008 9:18 AM

Tried the assembly (downloaded latest dll). Works fine on a local box. But on shared server end up with the error on:

Dim quantizer As OctreeQuantizer = New OctreeQuantizer(255, 4)

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.....

Tercüme wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Jan 7 2008 12:41 PM

Thanks

st3v3n wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Wed, Jan 30 2008 9:45 AM

The "Optimization..."article at the MS site has moved, to here;

msdn2.microsoft.com/.../aa479306.aspx

balık avı wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Thu, Jan 31 2008 4:33 PM

süperrrrrrrrrrrrr

youtube wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Mon, Feb 11 2008 4:54 PM

The "Optimization..."article at the MS site has moved, to here;

Oyun wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Tue, Feb 12 2008 8:32 PM

Great -- thanks for responding. I will plug it in and see how it goes..Again Thanks

youtube wrote re: Use GDI+ to Save Crystal-Clear GIF Images with .NET
on Sun, Feb 24 2008 2:38 PM

thanks a lot

Devlicio.us