Problem converting to 32ARGB bitmap

J

James Dean

I can display an 8bpp indexed bitmap correctly but when i tried to
convert this to 32ARGB then it didn't display properly at all. I am just
wondering how i can display the same 24bpp image at the the same width
and height as the previous 8bpp data. Is it possible that i can just
clone this data but i can't really as i am not allowed to create it i
think with an indexed bitmap. I set one byte to the corresponding index
color and this is how i display the 8bpp bitmap. How do i create a the
smae file but using 3 bytes for every color instead of one. I want to
keep my same width size of the actual image..how do i do that?......
 
B

Bob Powell [MVP]

You can create a copy of the image like this..

Bitmap bm=new Bitmap(original.Width, original.Height)
Graphics g=Graphics.FromImage(bm);
g.DrawImageUnscaled(original,0,0);
g.Dispose();

bm now contains a 32bpp copy of your 8 bit image.

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 
J

James Dean

Thats great Bob thanks. I cloned the 8bpp bitmap to another bitmap but i
gave this 32ARGB pixel format. If i don't use that image unscaled i
cannot save the bitmap properly..Is there any way i can actually save
that bitmap properly in 32ARGB...or do i always have to use the
imageunscaled to display it properly. I cannot seem to set the
transparent color either.....i thought using the same graphics object if
i just went g.Clear(Color.transparent)....it would set the background
color from black to white but it didn't...why is that?.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top