> 32 bit images don't require a palette. Only indexed image formatssuch as
> 8bpp or 1bpp will need them.
There are two ways to draw on an indexed image.
#1 Convert the indexed image to 24 or 32 bpp, draw on it and then save it as
an indexed image again.
#2 Draw the new pixels onto a 32 bpit per pixel image and then merge the two
using code that employs the LockBits method to access the byte array of the
indexed image directly.

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
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.
>> 32 bit images don't require a palette. Only indexed image formatssuch as
>> 8bpp or 1bpp will need them.
[quoted text clipped - 5 lines]
> images. What should I use instead? (I guess palettes but don't have a clue
> how :) ).
TroLoo - 27 Apr 2005 12:48 GMT
> #1 Convert the indexed image to 24 or 32 bpp, draw on it and then save it as
> an indexed image again.
Ok, it would mean that I have to remember PixelFormat of the image I'm
loading and after modifying it, convert to this base format, right?
Well, it's pretty straight forward and a good idea but requires
implementation of conversion alghorithms (24bpp->16bpp, 16bpp->8bpp,
etc.). As far as I know it's not that easy to convert image to indexed
format and save good quality of it (requires recalculation of palette by
some nice working alghorithm)... I'm thinking 'loudly' so that you can
either approve or reject my ideas :) Any help will be strongly appreciated!
But I have another small question - first I explain my idea: I create
24bpp bitmap of the same resolution as my original image and draw
original image on it. In this way I have no problem converting
PixelFormat upwards. But when I create new 24bpp Bitmap to draw original
image on it, I loose HorizontalResolution. For instance - I have 300dpi
image of size 1008 x 1491. After creating Bitmap of the same size, I
obtain 96dpi picture.
> #2 Draw the new pixels onto a 32 bpit per pixel image and then merge the two
> using code that employs the LockBits method to access the byte array of the
> indexed image directly.
Also good idea, I have to think about it a little :)

Signature
Regards,
TroLoo