0

I am making a counter for a game that requires the image to be 8-bit with a specific palette, otherwise it will not work.

I cannot do

 using (Graphics gr = Graphics.FromImage(base1))
                {
                   gr.DrawImage(base2, 0, 0);
                   gr.DrawImage(image4, 4, 21);

                   }

as the image is indexed, is there anyway to draw images to the base1 image, through pixels or whatever, and keep the palette? Or a way to obtain the palette, convert base1 to a new Bitmap, then index it with a specific palette after DrawImage?

  • It is stupid that GDI+ can't do that because the underlying Windows API can. The DrawImage API will let you blit from any format to any other format. If the destination is indexed, it just finds the closest match in the palette. – Moby Disk Apr 09 '15 at 17:03
  • Not DrawImage. StretchBlt and BitBlt. – Moby Disk Apr 09 '15 at 17:09
  • You can access the Palette via the Palette property. You can access the raw image using LockBits. Take a look at http://stackoverflow.com/questions/1319143 for a starting point. – Moby Disk Apr 09 '15 at 17:17
  • 1
    You need to do this the Right Way, create a normal non-indexed bitmap and don't convert to 8bpp until the last possible moment. Say, just before you need to save it. Getting a decent looking conversion isn't that simple either. You can get it from the GIF encoder but it isn't decent, its dithering algorithm is crude. Look at the AForge library for help. – Hans Passant Apr 09 '15 at 19:06

0 Answers0