473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Bitmap PixelFormat Conversion

Is there some way to convert a Bitmap from one PixelFormat (16bit or with
indexed colors) to another(24bit), without doing per pixel operations?
Nov 17 '05 #1
3 33512
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" <wr***@newsgroup.com> wrote in message
news:43*********************@news.tiscali.it...
Is there some way to convert a Bitmap from one PixelFormat (16bit or with
indexed colors) to another(24bit), without doing per pixel operations?

Nov 17 '05 #2
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" <wr***@newsgroup.com> wrote in message
news:43*********************@news.tiscali.it...
Is there some way to convert a Bitmap from one PixelFormat (16bit or with
indexed colors) to another(24bit), without doing per pixel operations?

Nov 17 '05 #3
Thank you !
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James Dean | last post by:
I create a bitmap like this. The width and height are got from the compressed file i am reading. The width and height are in pixels.....1bpp bitmap = new...
0
by: James Dean | last post by:
I save a 1bpp bitmap as a 1bpp png......i save this 1bpp png in a memorystream.....problem is i want to convert this back to a 1bpp bitmap but it always saves as a 32bpp bitmap....i need the 1bpp...
2
by: VicVic | last post by:
Hello Experts, I have 3 questions about Image and Bitmap, and hope you can help me. 1. Could any one tell me the difference between Image and Bitmap? I did take a look of the 2 classes, but...
5
by: Lance | last post by:
I need to create a Drawing.Bitmap from an array of integer values. My current technique creates a bitmap that eventually becomes corrupt (i.e., the bitmap's pixels change to a different color...
3
by: johnb41 | last post by:
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...
2
by: Sharon | last post by:
Hello Experts, I'm creating a bitmap object like this: Bitmap myImage = new Bitmap(1024, 1024, System.Drawing.Imaging.PixelFormat.Format24bppRgb); But when I invoking the function myImage...
0
by: news.microsoft.com | last post by:
Hi guys, This text looks long and complicate but it is not, and I really really need some help here. For the last 24hs I'm trying to resolve this issue (last night I dreamed
0
by: Craig | last post by:
Hi there, This could be a curly question. When I created the x11 bitmap image using the im.tobitmap() function I found out later that the display information in the array is big endian (I...
1
by: theShmit | last post by:
I am writing a regression testing suite that uses some image comparison features for some RFI (radio frequency interference) testing equipment. I capture an image (from the screen of the device),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.