C# how to create a simple graphic editor - part 1

  Рет қаралды 96,403

Dawisko1

Dawisko1

Күн бұрын

Пікірлер: 120
@PolyRocketMatt
@PolyRocketMatt 8 жыл бұрын
another question about this... When I try making the ellips, its giving me a 90° angle and then a circle around it, how can I fix this?
@AnaemicAn
@AnaemicAn 7 жыл бұрын
i have the same problem, did you fix it?
@FirstLast-ws7zw
@FirstLast-ws7zw 8 жыл бұрын
You can save up on the code like. if(e.Button == left) { //Do stuffs } No need to have a choose variable or assign two events. if the left mouse button is pressed down only then will the statement execute. Great tutorial btw.
@Dawisko1
@Dawisko1 11 жыл бұрын
Or as in select a part of image in the editor and control it? like move it, cut, copy and all these others?
@Dawisko1
@Dawisko1 11 жыл бұрын
Oh, about the 'red' and all not existing it's because you need to rename your trackBars and all controls to these names like The red color amount is represented by trackBar1.Value then rename 'trackBar1' to 'red' or use instead trackBar1.Value = paintcolor.R;
@Dawisko1
@Dawisko1 11 жыл бұрын
Draggable as in Drag and drop technique?
@SMB_Fan2010
@SMB_Fan2010 2 жыл бұрын
Why does the pencil tool draw a rectangle?
@MsLleonn
@MsLleonn 11 жыл бұрын
Hello Nice tutorial, but its kind of confusing to copy all of that since you had all the items allready set up in the design tab. Why do i keep getting the error for "red.Value = paintcolor.R;"and all the other colors, red gets underlined
@micproduction4033
@micproduction4033 11 жыл бұрын
Hello!Can you help me?Problem in this:redval.Text = paintcolor.R.ToString(); greenval.Text = paintcolor.G.ToString(); blueval.Text = paintcolor.B.ToString(); alphaval.Text = paintcolor.A.ToString(); C# write that Elements:greenval,redval,blueval,alphaval does not exist in this context.
@Dawisko1
@Dawisko1 11 жыл бұрын
Did you rename your objects? The redval, greenval, blueval, alphaval are names of objects, paintcolor on another hand is a global color variable. The most likely you don't have these labels on your GUI, just skip this part: redval.Text = paintcolor.R.ToString(); greenval.Text = paintcolor.G.ToString(); blueval.Text = paintcolor.B.ToString(); alphaval.Text = paintcolor.A.ToString(); And it should work.
@AmazingKing
@AmazingKing 2 жыл бұрын
I'm using 1.1 version, how do I get undo / redo buttons?
@mikimirai42
@mikimirai42 9 жыл бұрын
isn't there any way of making the cursor couldn't go out of picturebox2 while choosing the color?
@Dawisko1
@Dawisko1 9 жыл бұрын
+Ased Games (ased2) I don't think that's possible with just c#.
@mikimirai42
@mikimirai42 8 жыл бұрын
***** there is that funny problem my program crashes when I go out of the circle :D
@Dawisko1
@Dawisko1 8 жыл бұрын
actually, one way to stop that is to put the code in a try loop. That way all exceptions are handled, so the program won't crash.
@nasruddinkantebinramli2252
@nasruddinkantebinramli2252 8 жыл бұрын
hi, i actually cent get the trackbars to read the value off the colorwheel, even after i renamed the trackbars. i'm not sure if it is the color wheel. please help me.
@Dawisko1
@Dawisko1 8 жыл бұрын
Is there any kind of error, or just nothing is happening?
@nasruddinkantebinramli2252
@nasruddinkantebinramli2252 8 жыл бұрын
thank you for your quick reply. nothing is happening. im bot getting any movement in the trackbar, no value coming up. the picturebox not showing any colors indicated from the wheel.
@Dawisko1
@Dawisko1 8 жыл бұрын
That means the portion of code responsible for picking the color is not working, maybe it wasn't triggered, make sure the part of code is being executed (with breakpoints).
@nasruddinkantebinramli2252
@nasruddinkantebinramli2252 8 жыл бұрын
i'm sorry, but breakpoints? as in? so, I don't have to change the picture right. its the code at the picture? if so, could you please specify how? thanks for the help.
@Dawisko1
@Dawisko1 8 жыл бұрын
msdn.microsoft.com/en-us/library/5557y8b4.aspx
@XenonPhysics
@XenonPhysics 5 жыл бұрын
Excellent! Good job
@Dawisko1
@Dawisko1 9 жыл бұрын
+AFK Games I guess, though both are correct and today PCs are superior to those back in my time. I don't think any computer is having trouble processing it, unless it has about 128 MiB of RAM :P But in that case it would rather run on linux.
@AnaemicAn
@AnaemicAn 7 жыл бұрын
hey, in the 1.1 vesrion, why did you move the switch case from the mouse move to the mouse up event?
@AnaemicAn
@AnaemicAn 7 жыл бұрын
also, what is the use of the scalefactor variable ?
@Dawisko1
@Dawisko1 7 жыл бұрын
Anaemic in v1.1 in the mouseup event the actual drawing to the image is done. The paint event is used only for preview as for the scalefactor it's for the zoom
@AnaemicAn
@AnaemicAn 7 жыл бұрын
Oh, I understand. That's actually really smart. Thanks for the reply. Could some of the functionalities such as making the line function visible as it's drawn and bucket fill be done on the code you've shown us in this tutorial? The 1.1 version is very elaborate(the code almost looks nothing like v1.0) and I'm struggling to use it as means of "fixing" some of the functionalities shown here. Also, have you noticed that the rectangle function doesn't really work if you try to do a rectangle in any other direction other than the right-down? Interestingly, the ellipse works in all directions. Do you know why? Oh, and the ellipse function - when i try drawing the ellipse, it always starts with one angle being square, just like it does to you here, but it doesnt disappear. So im left with a teardrop shape instead of an ellipse. Any reccomendations on what to do? I'm sorry for bothering you - this is my first time doing sth in c# so im quite confused.
@Dawisko1
@Dawisko1 7 жыл бұрын
Anaemic well i can help you with that over skype, mine is:thor20121. I think Ican explain more there than on yt comments :)
@Dawisko1
@Dawisko1 7 жыл бұрын
Though i'll be online in about an hour or so
@Dawisko1
@Dawisko1 11 жыл бұрын
Ok, but what does the error message say?
@PolyRocketMatt
@PolyRocketMatt 9 жыл бұрын
Excuse me, When I Write the bitmap cosing, it says that red green, blue, alpha, and also the redval... doesn't exist in the current context, can you help me???
@Dawisko1
@Dawisko1 9 жыл бұрын
+MK Creators Animation Studios red, green, blue, alpha are the names of trackBars responsible for controlling the color values in the palette, redval is the "R: " label. It would seem your names for those controls are different.
@PolyRocketMatt
@PolyRocketMatt 9 жыл бұрын
Could you please say in wich video this isshowed how to make??? I'm currently making PaintR For Windows, (Because I really don't like FreshPaint on Win8!)
@Dawisko1
@Dawisko1 9 жыл бұрын
Sure, this one should cover that subject: kzbin.info/www/bejne/qGK1kIhtZ66jhpo
@PolyRocketMatt
@PolyRocketMatt 9 жыл бұрын
Thanks a lot, I did use normal file dialog, but now I can make my own one, Yeey!, One question, do you have skype, The I can ask some things if I don't udnerstand my own program :)
@Dawisko1
@Dawisko1 9 жыл бұрын
Sure, the username is thor20121.
@itzelsarmiento9975
@itzelsarmiento9975 9 жыл бұрын
Hi... I realle liked your video... But I wonder if you could tell me how you did your color pallette in circle... And I really apreciated if you could answer me... Thanks
@Dawisko1
@Dawisko1 9 жыл бұрын
Itzel Sarmiento It's actually simple, I used a pictureBox to display the palette and provide a graphical interface to get X and Y coordinates from user. But in the program a second bitmap is created virtually identical to the displayed one(cloned from the pictureBox), then the app gets the color value from the latter image. It's the bmp.GetPixel(X, Y); Where bmp is the latent bitmap. X and Y are coordinates provided by the user. The coding starts at 2:30.
@itzelsarmiento9975
@itzelsarmiento9975 9 жыл бұрын
Dawisko1 Thanks but if you culd help me with the code of the color pallette... I really need that and I'll be very greatfull for your help... could you?
@itzelsarmiento9975
@itzelsarmiento9975 9 жыл бұрын
Dawisko1 And your videos has been really usefull to me... But please could you help me?? :$
@Dawisko1
@Dawisko1 9 жыл бұрын
Itzel Sarmiento Sure, maybe we could talk it through on skype? My skype is thor20121
@itzelsarmiento9975
@itzelsarmiento9975 9 жыл бұрын
Dawisko1 Could we talk it through on text or e-mail...I don't have a skype acount...But I really need your help...The color pallette is my only problem... Could you please help me it's important and urgent...
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
I want to from all. I don't know what all the toolbox is used to create.
@Dawisko1
@Dawisko1 9 жыл бұрын
Arada Towadee So you want to know how to create the graphical interface? That will take a lot of time.
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
Dawisko1 yes, I want create interface. You create video teach interface ??
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
Dawisko1 I make project about create program paint please!!!
@Dawisko1
@Dawisko1 9 жыл бұрын
Arada Towadee Ok, I'll upload it in the forthcoming weekend.
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
Dawisko1 thank you
@j_k103
@j_k103 10 жыл бұрын
Can you help me? I'm getting a NullReferenceException in Bitmap bmp
@dawidskowronski6910
@dawidskowronski6910 10 жыл бұрын
Spróbuj tego: Bitmap bmp = (Bitmap)pictureBox1.Image.Clone(); Śmiało po polsku :)
@j_k103
@j_k103 10 жыл бұрын
Dawid Skowroński Dzięki,ale teraz jak klikam na paletę kolorów to dostaje coś takiego ArgumentOutOfRangeException was unhandled Value of '252' is not valid for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'.
@j_k103
@j_k103 10 жыл бұрын
Jakub Kuniszewski Dobra już naprawiłem xD
@GonzlandandPibby
@GonzlandandPibby 2 жыл бұрын
"Simple" Paint: Looks very advanced.
@Dawisko1
@Dawisko1 11 жыл бұрын
Ok, i see the error. You see c# is strong typing language it means that it's case-sensitive, like it does not contain a method for Tostring(), becuase it's not Tostring() but ToString(). So it should be not like this: greenval.Text = paintcolor.G.Tostring(); blueval.Text = paintcolor.B.Tostring(); alphaval.Text = paintcolor.A.Tostring(); but, like this: greenval.Text = paintcolor.G.ToString(); blueval.Text = paintcolor.B.ToString(); alphaval.Text = paintcolor.A.ToString();
@blacklisted9988
@blacklisted9988 10 жыл бұрын
Hey i am also getting an error NullReferenceException on Bitmap bmp = (Bitmap)pictureBox1.Image.Clone(); need help over here..
@Dawisko1
@Dawisko1 10 жыл бұрын
Check the name of the object from which you want to pick the image, if they are correct make sure the pictureBox image param is set.
@keaan5284
@keaan5284 4 жыл бұрын
Thank you for this tutorial you are amezing
@gabrieltaylor5382
@gabrieltaylor5382 8 жыл бұрын
Hey Dawisko1 do you have to be knowledgeable in C# in order to do this and add stuff to it? I'm going to being learning some C++ so I'm guessing it'll help me a little. What are your thoughts about this? Or should I just learn C#?
@Dawisko1
@Dawisko1 8 жыл бұрын
Gabriel Taylor to be honest, it doesn't matter. If you learn c++ you won't have any problems with programming in c# or any other language. However it's definitely easier to learn c# rather then c++.
@mihaimihai3528
@mihaimihai3528 8 жыл бұрын
This example DO NOT SAVE THE IMAGE. CreateGraphics is just a temporary canvas, so you rarely, if ever, use that for drawing purposes, if you try to save the paint to an image. Instead define a Bitmap property and on the Paint event of the panel draw the bitmap on the panel like this: void panel1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawImage(bmp, Point.Empty); } and on the mouse down event use the graphics from the image using (Graphics g = Graphics.FromImage(bmap)) { g.FillEllipse(Brushes.Black, e.X, e.Y, 10, 10); } panel.Invalidate(); Like this. The example above is working fine until you want to save the paint to a file. Then you will see that the image comes in blank.
@siresorb1419
@siresorb1419 7 жыл бұрын
Mihai Mihai what part of the code had you think that was a function?
@siresorb1419
@siresorb1419 7 жыл бұрын
Mihai Mihai did you try printing it on the canvas?
@yoloson1187
@yoloson1187 3 жыл бұрын
red.value is causing issues, started with a blank project.
@prasenjeetanand
@prasenjeetanand 7 жыл бұрын
My brush and other obj draw continues after click. Plz help
@Dawisko1
@Dawisko1 7 жыл бұрын
Check the if statement in MouseMove event, if it's ok make sure the bool is set to true in MouseDown event and in the MouseUp event the bool is set to false.
@prasenjeetanand
@prasenjeetanand 7 жыл бұрын
Dawisko1 thanks sir its works.
@prasenjeetanand
@prasenjeetanand 7 жыл бұрын
First time I got reply that fast.
@Mangaia0103
@Mangaia0103 8 жыл бұрын
Hey man I'm looking for a code for something like this but with a bit more feature and I need help making it can you help me ? because i have a deadline untill 21st jan. (I'm a student) and they don't learn us shit and I have no idea how to do this ...
@Dawisko1
@Dawisko1 8 жыл бұрын
No problem, my skype is: thor20121
@RickyDivjakovski
@RickyDivjakovski 7 жыл бұрын
Should turn this into a custom control, great tutorial, will be making a tutorial similiar to this, although im having problems drawing a line without white spots showing up, ive got with a Pen(color, size), but when making the pen above 20 in size i also get white spots, i may give filling a pie in the respected xy coordinates a shot, problem is calculating the rectangle with will be annoying
@Dawisko1
@Dawisko1 7 жыл бұрын
Thanks, though as for the white spots it's actually the drawing speed. I think one way to counter it is instead of drawing small ellipses drawing a curve from the (x, y) coordinates collected in the mouse_move event.
@RickyDivjakovski
@RickyDivjakovski 7 жыл бұрын
i noticed, i solved this just then with g.FillPie(new SolidBrush(selectedColor), new Rectangle(startPointX - lineWidth / 2, startPointY - lineWidth / 2, startPointX + lineWidth / 2, startPointY + lineWidth / 2), 0, 360); problem i now face is a wierd pie being drawn
@RickyDivjakovski
@RickyDivjakovski 7 жыл бұрын
the width is quite big
@RickyDivjakovski
@RickyDivjakovski 7 жыл бұрын
similar to your error when you first drew the filled rectangles
@Dawisko1
@Dawisko1 7 жыл бұрын
That was because I mixed the variables. Maybe it's the same for you :)
@itzelsarmiento9975
@itzelsarmiento9975 9 жыл бұрын
Hi... It's been so long... I wanted to ask you help with the code again... It's steel doesn't paint at all it change color but it doesn't paint or draw anything... Could you please help me again....? Thanks...
@Dawisko1
@Dawisko1 9 жыл бұрын
Itzel Sarmiento Sure, but as usually I will need to see the code, it'll be easier and faster.
@MsLleonn
@MsLleonn 11 жыл бұрын
The name 'red' does not exist in the current context same error for every other color: Error 9 'byte' does not contain a definition for 'Tostring' and no extension method 'Tostring' accepting a first argument of type 'byte' could be found (are you missing a using directive or an assembly reference?) even my proffesor couldn't find what was wrong so i was wondering if you can help me :)
@katakanacristatus8123
@katakanacristatus8123 7 жыл бұрын
the eilipse tool doesn't work properly :( case Item.Eilipse: g.FillEllipse(new SolidBrush(paintcolor), x, y, e.X - x, e.Y - y); break; copied your code to the tee yet, I get a 90° angle, very frustrating -_- I hope you can help me fix this. I must be missing something...Everything else works fine :) Anyway great tutorial! :)
@Dawisko1
@Dawisko1 7 жыл бұрын
That is actually not an error, it's due to lack of refreshing while drawing the object. Anyways it was solved in v1.1: sourceforge.net/projects/mainpaint/
@katakanacristatus8123
@katakanacristatus8123 7 жыл бұрын
thankyou so much! :)
@wilfredomandujano3254
@wilfredomandujano3254 9 жыл бұрын
you tutorial is good and helped me so much...!
@shaikhbushra3371
@shaikhbushra3371 8 жыл бұрын
fizz buzz game in python using gui
@c4geekblog
@c4geekblog 9 жыл бұрын
Thank you so much this is very helpful!
@Dawisko1
@Dawisko1 11 жыл бұрын
What do you mean it's weird?
@clarkwilliams9930
@clarkwilliams9930 9 жыл бұрын
redval, greenval... wtf is this ? And what are your track bars maximum value ?
@Dawisko1
@Dawisko1 9 жыл бұрын
Clark Williams redval, greenval and blueval are the labels, and the trackbars maximum value is 255, which is the maximum of each color component in the Color structure.
@h3wrnest
@h3wrnest 9 жыл бұрын
Nice video! Thanks so much!!!
@chimp8350
@chimp8350 8 жыл бұрын
Hello bro, do you have a code for graphic editor for android?
@Dawisko1
@Dawisko1 8 жыл бұрын
Nope, I'm not into programming for Android. Though look it up on Google, I'm sure there are lots of examples :D
@Dawisko1
@Dawisko1 11 жыл бұрын
Masz rację, nawet nie zwróciłem uwagi. Dziękuje
@egorchengwk
@egorchengwk 5 жыл бұрын
i can't draw inside picturebox1
@chrisanders7257
@chrisanders7257 11 жыл бұрын
can you share the source code?
@YellowRedBrick
@YellowRedBrick 5 жыл бұрын
NIce job!!!
@gurmeetsinghvirdi6849
@gurmeetsinghvirdi6849 7 жыл бұрын
Too good tutorial
@tasnimalfaridi3955
@tasnimalfaridi3955 10 жыл бұрын
is it free or not ?
@Dawisko1
@Dawisko1 10 жыл бұрын
Basically it's just a template, so yes :)
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
I want to teach you how to create a step-by-step program page
@Dawisko1
@Dawisko1 9 жыл бұрын
Arada Towadee Here is the tutorial in which the form is explained and is shown how to create it: kzbin.info/www/bejne/qGK1kIhtZ66jhpo
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
Dawisko1 thank you very much
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
Dawisko1 I write code red.Value = paintcolor.R; green.Value = paintcolor.G; blue.Value = paintcolor.B; alpha.Value = paintcolor.A; error .Value because??
@Dawisko1
@Dawisko1 9 жыл бұрын
Arada Towadee Well, did you rename all of the trackbars?
@aradatowadee5836
@aradatowadee5836 9 жыл бұрын
ok
@Dawisko1
@Dawisko1 11 жыл бұрын
I need to see the code in real time. Is there any chance you could meet up with me on skype at 17:00 of my time? Then maybe i'll be able to help you out.
@GameWithBrony
@GameWithBrony 11 жыл бұрын
We can simply see, he is from Poland... Me too :D He said (1:09) x, "igrek" but not "y". ~~~~ Part in Polish Spoko poradnik, ale tu zwaliłeś sprawę z angielszczyzną :P
@TechXSoftware
@TechXSoftware 11 жыл бұрын
Watching this on my ipad, it's a but weird
@itzelsarmiento9975
@itzelsarmiento9975 9 жыл бұрын
Hi... I send you aún e-mail... If you could help me it'll be great...
@Dawisko1
@Dawisko1 11 жыл бұрын
Sure, it's d.s.h12421@gmail.com
@ryanmcdonald2027
@ryanmcdonald2027 4 жыл бұрын
This is not a good video ! u have not showed me how to add the design layout for all the buttons and the sliders ! :( And you have not started the code from the very beginning either ! :(
@Dawisko1
@Dawisko1 4 жыл бұрын
Lol, you can pause and recreate it or get the source like us normal folk. Besides design the UI yourself, this one really isn't the best.
C# how to create a simple graphic editor - part 2
26:12
Dawisko1
Рет қаралды 22 М.
Hacking An Obscure Game From 2000 To Run On Windows 11
16:22
Nathan Baggs
Рет қаралды 105 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
C# .NET Windows Form | СОЗДАЁМ PAINT НА C#
23:40
ChannelOf TwoGentlemen
Рет қаралды 56 М.
Python laid waste to my C++!
17:18
Sheafification of G
Рет қаралды 133 М.
Making a Game With C++ and SDL2
8:14
PolyMars
Рет қаралды 1,7 МЛН
How Old Can a File Be?
12:11
Dev Detour
Рет қаралды 30 М.
It Was SO Much WORSE! The FULL Story of Lion Air flight 610
1:06:12
Mentour Pilot
Рет қаралды 852 М.
This is the code that sent Apollo 11 to the moon (and it’s awesome)
19:09
C# Programming - Drawing Using The Graphics Class
19:56
Bill Butterfield
Рет қаралды 84 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН