You must create a new bitmap of the same size as the indexed one and then
draw the indexed bitmap to the new bitmap. This will convert all the colours
to 32 bit and enable you to draw on the bitmap.
Bitmap bm=new Bitmap(org.Width, org.Height <,optional pixel format>);
bm.SetResolution(org.HorizontalResolution, org.VerticalResolution);
Graphics g=Graphics.FromImage(bm);
g.DrawImage(org,0,0);
//continue to draw on g here to add text or graphics.
g.Dispose();
bm.Save(......);
--
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.
"johnb41" <or****@informatik.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I need to use the bitmap.getpixel method to work on the pixel level of
an image. But GetPixel will not work with Indexed images. The images
that i work with are black & white text scans.
I create the bitmap object like this:
Dim b As Bitmap = Bitmap.FromFile("c:\scan.tif")
But I want to convert this file to PixelFormat.Format24bppRgb (or
something NOT indexed)
PixelFormat.Format24bppRgb is Read Only, so i can't simply do:
b.pixelFormat = PixelFormat.Format24bppRgb
Bitmap has an overload that allows the Pixelformat to be specified, but
the overload cannot accept a file name for my tiff, just a width and
height. If I use that overload, my bitmap object ends up blank. I
need it to hold image data.
I'm totally stumped. Can anyone help?
Thanks!
John