Connecting Tech Pros Worldwide Forums | Help | Site Map

convert image file to 24bpp bmp

Newbie
 
Join Date: Nov 2008
Location: UK
Posts: 28
#1: 4 Weeks Ago
Hi

I'm trying to save a webcam image to a 24 bpp bmp using

pictureBox1.Image.Save("c:/users/Mark/Desktop/pictureBox1.Bmp", System.Drawing.Imaging.ImageFormat.Bmp);

but I keep on getting the wrong format. Any ideas what I'm doing wrong

thnx

mrcw

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,167
#2: 4 Weeks Ago

re: convert image file to 24bpp bmp


Try picking the specific bitmap type you want.
Somewhere you can set PixelFormat.Format24bppRgb
Newbie
 
Join Date: Nov 2008
Location: UK
Posts: 28
#3: 3 Weeks Ago

re: convert image file to 24bpp bmp


I think I am making a new 24bpp bmp that is the right size and format. But the bmp is black or empty. How do I assign or put the image into the bmp?
Expand|Select|Wrap|Line Numbers
  1.  private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             //Loads image from disk puts it into picturebox1
  4.             pictureBox1.Image = Image.FromFile("c:/users/Mark/Desktop/pictureBox1.Image");
  5.  
  6.             //copys image from picturebox1 to picturebox2
  7.             pictureBox2.Image = pictureBox1.Image;
  8.  
  9.             //pictureBox2.Image = new Bitmap(pictureBox2.Width, pictureBox2.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
  10.  
  11.             // declares new bitmap called pic
  12.             Bitmap pic;
  13.  
  14.             //makes pic bitmap same size as picturebox1.image
  15.             pic = new Bitmap(pictureBox1.Width, pictureBox1.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
  16.  
  17.             //Finds edges of pic
  18.             ReplaceImage(EdgeFinder((Bitmap)pic));
  19.  
  20.         mrcw
  21.  
  22.         }
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,167
#4: 3 Weeks Ago

re: convert image file to 24bpp bmp


Create a Graphics object from your new bitmap, then use the DrawImage functions to put the bitmap onto it.
Reply