graphics - C# bitmap drawing doesn't render to the screen -


I am trying to write a drawing program for use with a tablet. For this I need to use pressure to reduce and transparency. Therefore I am doing the image creation using bitmap system in C #.

To display anything to me, I can not get my drawing code right now, it is being given in the picture box. I know that some things are getting input for bitmap because it shows when I save a bitmap

I have taken a look at many C # drawing questions, which is used by the line To use drawing or oval drawing goods, the opposite of bitmap is

  using the system; Using System.Collections.Generic; Using System.ComponentModel; Using System.Data; Using System.Drawing; Using System.Linq; Using System.Text; Using System.Windows.Forms; Namespace Paint 1 {Public Partial Category Form 2: Form {Public Bitmap m_bitmap; Public Bull m_penDown; Public int m_lastX; Public int m_lastY; Public Inc. m_currentX; Public int m_currentY; Public form 2 () {initialization (); // Create a bitmap area m_bitmap = new bitmap (this .Withth, it.height, system.documentation.imaging.pixel format.format24bpRGB); M_penDown = false; Graphics m_graphics = Graphics. Framesize (m_bitmap); M_lastX = System.Windows.Forms.Cursor.Position.X; M_lastY = System.Windows.Forms.Cursor.Position.Y; M_currentX = System.Windows.Forms.Cursor.Position.X; M_currentY = System.Windows.Forms.Cursor.Position.Y; } Private Zero form 2_load (Object Sender, EventEurge E) {} Private Void Form 2 page (Object Sender, Paint Event ARGS E) {Graphics OzGix; // you e Graphics can not directly modify the objGraphics = e.Graphics; // Draw the content of the bitmap on the form ObjGraphics.DrawImage (m_bitmap, 0, 0, m_bitmap.Width, m_bitmap.Height); ObjGraphics.Dispose (); } Private Zero Picture Box 1_MouseDown (Object Sender, MouseEventArgs e) {m_penDown = true; } Private Zero Picture Box 1_MouseUp (Object Sender, MouseEventArgs e) {m_penDown = false; } Private Zero Picture Box 1_MouseMove (Object Sender, MouseEventArgs e) {m_lastX = m_currentX; M_lastY = m_currentY; M_currentX = System.Windows.Forms.Cursor.Position.X; M_currentY = System.Windows.Forms.Cursor.Position.Y; If (m_penDown) m_bitmap.SetPixel (m_currentX, m_currentY, Color.Gray); } Private zero imagebox 1_Paint (object sender, paint event ARG E) {form 2 page (sender, e); This.pictureBox1.Image = m_bitmap; } Private Zero form 2_keyview (Object Sender, KAVEEVER E. E) {if (E.Code == Keys. Space) {m_bitmap.Save (@ "C: \ user \ rpettefar \ Documents \ My Dropbox \ Programming \ Paint 1 \ Preview. BMP ", System.Drawing.Imaging.ImageFormat.bmp); }}}}   

I am slightly new to C #, so I am open to any other issues or things that may come to your attention.

You must assign your bitmap in the photo box.

  myPictureBox.Image = m_bitmap;   

You can then change the bitmap or assign it once and then invalidate your picturebox.

  myPictureBox.Invalidate ();   

It tells your form to refresh the picture on the screen. There is no need to override OnPaint Draw on a bitmap using the graphics object created in the constructor of the form (if you want to make more complex things than pulling single pixels). Picturebox will work the rest

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -