PC Review


Reply
Thread Tools Rate Thread

Bitmap PixelFormat Conversion

 
 
Flix
Guest
Posts: n/a
 
      20th Sep 2005
Is there some way to convert a Bitmap from one PixelFormat (16bit or with
indexed colors) to another(24bit), without doing per pixel operations?


 
Reply With Quote
 
 
 
 
Bob Powell [MVP]
Guest
Posts: n/a
 
      20th Sep 2005
You can convert from any format to 32 or 24 bpp easily. However, converting
to an indexed format from either of those requires the use of per-pixel
operations.

Ideally you'd use LockBits to facillitate these operations

See the GDI+ FAQ for details. It demonstrates LockBits and how to convert
from 32bpp into 1bpp.

--
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.





"Flix" <(E-Mail Removed)> wrote in message
news:433034f5$0$8476$(E-Mail Removed)...
> Is there some way to convert a Bitmap from one PixelFormat (16bit or with
> indexed colors) to another(24bit), without doing per pixel operations?
>



 
Reply With Quote
 
Christiaan Nijdam
Guest
Posts: n/a
 
      20th Sep 2005
Hi Flix,

I found this:

private void button3_Click(object sender, System.EventArgs e)
{
Bitmap b1=new Bitmap("augustinus_16ColorBitmap.bmp");

Bitmap b2=new
Bitmap(b1.Size.Width,b1.Size.Height,System.Drawing.Imaging.PixelFormat.Forma
t24bppRgb);
Graphics g = Graphics.FromImage(b2);
g.DrawImage(b1,new Point(0,0));
g.Dispose();

System.Console.WriteLine("b1.PixelFormat="+ b1.PixelFormat.ToString());
System.Console.WriteLine("b2.PixelFormat="+ b2.PixelFormat.ToString());

this.BackgroundImage=b2;
}

Christiaan.



"Flix" <(E-Mail Removed)> wrote in message
news:433034f5$0$8476$(E-Mail Removed)...
> Is there some way to convert a Bitmap from one PixelFormat (16bit or with
> indexed colors) to another(24bit), without doing per pixel operations?
>
>



 
Reply With Quote
 
Flix
Guest
Posts: n/a
 
      22nd Sep 2005
Thank you !


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitmap(int, int, int, PixelFormat, IntPtr) equivalent on CF? Thorium Microsoft Dot NET Compact Framework 0 10th Aug 2007 08:52 AM
Why the Bitmap.MakeTransparent() changes the PixelFormat ? =?Utf-8?B?U2hhcm9u?= Microsoft C# .NET 2 28th Feb 2006 06:51 AM
Supported Bitmap PixelFormat =?Utf-8?B?U2NvdHQgQmVsbW9udGU=?= Microsoft Dot NET Compact Framework 0 20th Feb 2006 11:54 PM
PixelFormat.Format8bppIndexed in Bitmap Hangs! Mil Microsoft C# .NET 0 13th Jan 2006 07:29 AM
How to "set" the PixelFormat for a bitmap? johnb41 Microsoft VB .NET 3 13th Jul 2005 08:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:15 AM.