It is not possible to create a Graphics object from an indexed pixel format.
However, you may load and save indexed pixel formatted images. You can test
to 8bpp but you may not be happy with the result of the color reduction. If
"Jim Light" <dejavue82@yahoo.com> wrote in message
news:1169251432.252253.16120@a75g2000cwd.googlegroups.com...
> Hi Bob,
>
> Thank you for your informative answer! The reason I asked is as
> follows:
>
> II wrote a small C# routine that resizes images from a stream input.
> During a test of the routine, I tried to upload a gif file and got the
> following error:
>
> "A Graphics object cannot be created from an image that has an indexed
> pixel format."
>
> then I changed the line "Bitmap bitmap = new Bitmap(width, heigth,
> img.PixelFormat);"
>
> to
>
> "Bitmap bitmap = new Bitmap(width, heigth);"
>
> Now I can create a Graphics object from a gif file. However, since this
> problem occured, I can't be sure that all different types of gifs,
> jpegs, and tiffs can be processed by this routine correctly. Is there a
> way to be sure?
>
> Thank you.
>
> Regards,
>
> Jim
>
> Bob Powell [MVP] wrote:
>> Tiff can because tiff does everything, I don't think jpeg can.
>>
>> Even though tiff can support the format the GDI+ codecs don't support
>> this version of tiff encoding.
>>
>> The other types of indexed format supported by GDI+ is the fax format of
>> 1 bit per pixel and the 4 bit per pixel 16 colour.
>>
>> --
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Ramuseco Limited .NET consulting
>>
http://www.ramuseco.com >>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>>
http://www.bobpowell.net/tipstricks.htm >>
>> Answer those GDI+ questions with the GDI+ FAQ
>>
http://www.bobpowell.net/faqmain.htm >>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> Jim Light wrote:
>> > Hi,
>> >
>> > I know that Gif images have an indexed pixel format, However it is
>> > possible for Tiffs and jpegs to also have this format?
>> >
>> > Thank you for your time.
>> >
>> > Regards,
>> >
>> > Jim.
>> >
>