473,387 Members | 1,742 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,387 software developers and data experts.

Microsoft Paint functionality in C#

I am looking for some simple code samples in C# that emulates
Microsoft Paint. There is the .NET Paint program but that code sample
is fairly complex. I need to be able to load a picture and then draw
ink on that picture using the pen, rectangle, ellipse, etc. Anyone
know of a some sample code to get me started with other than just the
basic DrawEllipse method where I have to pass it a coordinate
everytime the mouse moves. Thanks.
Nov 16 '05 #1
1 3145
Scott,

I am not sure what you are looking for really. In essence, that is
really what you have to do when you want to draw things like rectangles,
ellipses, etc, etc.

For drawing with a pen, you just have to keep track of the mouse
movements while the button is down. You basically would keep track of each
point that the mouse is at while it moves, and then draw a line from the
last point to the current point using the selected pen.

For drawing rectangles and ellipses, the procedure is pretty much the
same. You would store the initial point where the button was clicked, and
store the location of the last point that the mouse moved on as well. As
the mouse moves, you would have to "erase" the last rectangle you drew (if
anything, you might want to store the image bits, or xor the
rectangle/ellipse over the image, so you can easily reverse the operation),
and then draw a new one. When you release the mouse, you would leave the
rectangle as it is.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Scott" <sc**********@mdsint.com> wrote in message
news:37**************************@posting.google.c om...
I am looking for some simple code samples in C# that emulates
Microsoft Paint. There is the .NET Paint program but that code sample
is fairly complex. I need to be able to load a picture and then draw
ink on that picture using the pen, rectangle, ellipse, etc. Anyone
know of a some sample code to get me started with other than just the
basic DrawEllipse method where I have to pass it a coordinate
everytime the mouse moves. Thanks.

Nov 16 '05 #2

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

Similar topics

1
by: ktcute | last post by:
I'm trying to write a simple drawing tool that saves images out as jpgs. I've been using the paint event on the Panel control to draw the objects, however I couldn't get the same drawing...
2
by: Gregory Hawke | last post by:
What would be the easiest way of painting a titlebar in a form? Setting the background property of a derived System.Windows.Forms.Form only paints the client area. I need to paint the frame as...
3
by: Macca | last post by:
Hi, I have been using MS paint to manipulate bitmaps by adding layers and points to existing bitmaps. I need to know where in the bitmaps i have been adding layers and points and paint tells me...
7
by: Schorschi | last post by:
I know there is a way to do this, but I don't know how. Via a custom event? I have some code that I only want to run during a paint event. I could build a form instance that has the code and...
41
by: Rob R. Ainscough | last post by:
I keep hearing persistant rumors (along with my own experience) that .NET is going to be abandon by Microsoft due to performance & security issues? I realize no one from Microsoft is likely to...
1
by: Peted | last post by:
is it possible to use a lineargradientbursh to paint a gradient onto a button control, but have the button keep all its functionality, and visual functions, so that it still looks like a...
3
by: Fromethius | last post by:
Hello everyone I'm trying to write a program in native c++ code that will do this: When drawing in MS Paint and I press the P key on the keyboard, the Pencil tool will become the current tool....
7
by: Rotsey | last post by:
Hi, I have a interface that I use for a form so I can pass the form to another object. How do I add the Paint event to the interface and subsequently handle the paint event in my other...
15
by: jim | last post by:
Maybe I'm missing something, but it doesn't look like Microsoft writes a lot of apps in .Net (although they certainly push it for others). What does MS write using pure .Net? If applications...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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,...

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.