Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How to draw a bitmap with 1 bit depth in the picureBox of VS2010

$
0
0

    Hello, I want to get the bitmap with 1 bit depth in the pictureBox of VS2010. But I could only get the bitmap with 32 bit depth. Part of the program codes:

         

                Bitmap bm1 = new Bitmap(1024, 768);
                Rectangle rg = new Rectangle(0, 0, 1024, 768);
                Graphics g = Graphics.FromHwnd(this.Handle);
                g = Graphics.FromImage(bm1);
                g.FillRectangle(System.Drawing.Brushes.Black, 0, 0, 1024, 768);
                g.DrawImage(bm1, rg);
                pictureBox1.Image = bm1;

    I could get the bitmap with 32 bit depth from the program code. It is not convenient to change every bitmap from 32 bit depth to 1 bit depth. If I want to get the bitmap with 1 bit depth directly, how should I modify my program codes.

    Please give me some clues. Thank you very much. I will appreciate your answers.

 

Viewing all articles
Browse latest Browse all 12583

Trending Articles