none
Graphics object doesn't play well with indexed pixel format. RRS feed

  • Question

  • I am working with black and white tiff files - specifically I would like to create and place text as well as graphics inside of them. 

    However, the following code produces an exception:


                Bitmap myBitmap = new Bitmap(100, 100, PixelFormat.Format1bppIndexed);

                try
                {
                    using (Graphics g = Graphics.FromImage(myBitmap))
                    {
                        //do some work
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

    The exception created is:

    A Graphics object cannot be created from an image that has an indexed pixel format. 

    My questions are:

    Why?

    Will this ever be fixed?

    Is there a work around?

    Tuesday, September 19, 2006 4:56 PM

Answers

  • GDI+ has very poor support for indexed pixel formats.  Load and save, that's about it.  I seriously doubt this will ever get fixed.
    Tuesday, September 19, 2006 10:22 PM
    Moderator