David Galea

David Galea

  • NA
  • 12
  • 0

Bitmaps in Forms

Feb 18 2009 10:51 PM
hey guys,

Please excuse any improper terminology, I'm fairly new to Windows applications in C#. I am trying to create a basic Windows Application with one Form, that will contain a Bitmap Image, however I don't want the whole Form to be the Bitmap Image, a centre Rectangle so to speak.
At this point I have been using a PictureBox which I then 'insert' a Bitmap Image, although it seems over the top with the functionability I want to implement being,

When the user moves over the Image and is pressing the Left Mouse Button, the Bitmap Image is updated to include that point (Set Pixel) with a Black Dot in the Bitmap (similar to that of drawing a curve with the brush in Paint), however the only way I can get it to work so far is to use the following

// There is an event which tests whether or not the left button is pressed and whether the mouse is moving
Bitmap B = new Bitmap(this.MyImageBox.Image, MyImageBoxs_Size)
B.SetPixel(e.X,e.Y, Color.Black)  // e = MouseEvent args e
this.MyImageBox.Image = (Image) B;

Would it not be easier if I had some other form of container for the Bitmap Image?? or am I able to have the Bitmap Image sitting directly on the Form with no container at all?? and if so, how do I go about this?

Any guidance would be greatly appreciated,

David

Edit - I'm been doing some research on the net, would it be easier to have a Bitmap on the form (as before within some sort of container or centred in the form) and use a Pen to draw onto the Bitmap?

Answers (5)