Click here to Skip to main content
15,882,152 members
Everything / Drawing

Drawing

drawing

Great Reads

by honey the codewitch
Explore techniques for drawing using GFX
by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.
by Garvit Arya
It is a JavaScript based application for drawing basic free-hand shapes, logos and drawings.
by Swagat Parida
Steps to create a simple drawing app using HTML5 Canvas

Latest Articles

by Minh Danh Nguyen (ToughDev)
This is a cheap 320×240 2.8″ TFT LCD module that uses the ILI9320 controller for the display and the XPT2046.
by honey the codewitch
Use GFX effectively with e-paper/e-ink displays
by honey the codewitch
Explore techniques for drawing using GFX
by honey the codewitch
Explore the inner workings of a highly capable IoT display driver for the ESP32

All Articles

Sort by Score

Drawing 

3 Jun 2021 by honey the codewitch
Explore techniques for drawing using GFX
4 May 2021 by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.
1 May 2012 by Sergey Alexandrovich Kryukov
This is because you are doing it wrong. Actually, this is a pretty common mistake.The rendering of graphics persists only if you perform it on each WM_PAINT Windows message. For this purpose, you should handle the event System.Windows.Forms.Control.Paint, or, better yet, override the virtual...
27 Apr 2012 by Sergey Alexandrovich Kryukov
I'm adding this answer for clarification of my comment to the answer by VJ.Please see my past answer explaining why you should not use PictureBox and what to do instead:How do I clear a panel from old drawing[^].This answer explains how to write in both image and a control:draw a...
15 Jun 2014 by Garvit Arya
It is a JavaScript based application for drawing basic free-hand shapes, logos and drawings.
19 Dec 2015 by Swagat Parida
Steps to create a simple drawing app using HTML5 Canvas
18 Jun 2021 by honey the codewitch
Use GFX effectively with e-paper/e-ink displays
29 Mar 2012 by Frank R. Haugen
I have a half-finished tool for calculating distances between real-life stars, and positions in space, and much more, but I'd like to make a 2D map of the 100'000 closest stars, but I need some advise.Firstly; making the position X=0 and Y=0 location dead center of the program window, (with...
30 Mar 2012 by Shahin Khorshidnia
Hello,If I've taken the point:1. you need to Convert Point to Cartesian coordinate:private Point ConvertCartesianToPoint(Point point){ double width = this.SkyCanvas.ActualWidth; double height = this.SkyCanvas.ActualHeight; double x = point.X; double y =...
12 Apr 2012 by Chris Ross 2
It's hard to give advice without knowing your actual level of experience. You say you're a newbie, however, so I'll assume that there's more you don't know (but need to) than what you do know.I would start by researching the simple mechanics of printing from a .Net app. Forget about bar...
29 Nov 2012 by Sergey Alexandrovich Kryukov
For orientation, you need to use System.Drawing.Graphics.Transform:http://msdn.microsoft.com/en-us/library/system.drawing.graphics.transform.aspx[^],http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.matrix.aspx[^].Besides, it looks you are trying to use the class...
5 Feb 2013 by fjdiewornncalwe
The syntax error you are receiving is because of the semi-colon at the end of your function declaration which causes the spriteBatch variable on the next line to be out of scope.public void Draw(SpriteBatch spriteBatch);
28 Mar 2014 by OriginalGriff
Exactly how you do it depends on you, and what you have put in your City class - but I notice that the City constructor accepts and X and Y position: city = new City(textBox1.Text, e.X, e.Y, greenPen);So you could just have a public Location property in the City class: public Point...
5 Jun 2014 by Sergey Alexandrovich Kryukov
Don't ever draw anything on a PictureBox. This is one of the common mistakes of many beginners confused by this almost useless class, only designed to simplify the most basic graphic chores, like presenting a static image. Even though manipulating with PictureBox is possible, it will give you...
2 Jun 2015 by Sergey Alexandrovich Kryukov
The problem is that you never use your VisualCollection, only create it. How do you think the rest of your application can "know" that this collection even exist?You don't even need this fictional "Loaded" event; you can call the code adding visuals from the constructor directly. For...
11 Dec 2015 by CHill60
Have a look at this CP article Professional C# - Graphics with GDI+[^]There is also a reference zone[^] here on CPOr there always the M$ documentation[^]
31 Aug 2017 by RickZeeland
In addition to the nice article mentioned by Graeme (which deserves points really) Making Transparent Controls - No Flickering[^] , the following: If you want to "punch a hole", this article might be of interest: Phil Wright : Component Factory: .NET2, Transparent controls[^] Also using...
19 Sep 2020 by Richard MacCutchan
The only thing I can see that may be an issue is the following: FillRgn(hdc, hrgnClip, CreateSolidBrush(color)); DeleteObject(SelectObject(hdc, GetStockObject(WHITE_BRUSH))); Are you certain that DeleteObject is actually deleting the solid brush?
25 Apr 2021 by honey the codewitch
Explore the basic drawing functionality provided by the GFX IoT library
6 May 2021 by honey the codewitch
Explore the inner workings of a highly capable IoT display driver for the ESP32
14 Aug 2011 by spitfire_ch
Finally, I could figure out some explanations and partial solutions to the above problems: *To my understanding, Invalidate() -> Update() should be equal to Refresh(). Apparently, it's not. Refresh() does more.Wrong, Refresh() equals Invalidate(true) -> Update()MS description of this...
16 Dec 2011 by OriginalGriff
Technically speaking, you can't. Drawing anything over the top of controls is not something anyone expected you would want to do, probably because it is kinda ugly!But, it is possible - you just have to use a kludge.In your form load event, add: Panel pan = new Panel(); ...
25 Mar 2012 by Sergey Alexandrovich Kryukov
It has nothing to do with MDE. You can do it with any control, including System.Windows.Form.Form.First of all, to get mouse coordinates, handle appropriate mouse events; please see:http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx[^].Alternatively, subclass...
4 Jun 2012 by BillW33
Read this[^] for the basics on drawing with WPF. Also read this[^] article.
13 Jun 2012 by Tim Corey
Here is a basic article that will help you figure out how to draw these shapes:http://msdn.microsoft.com/en-us/library/ms747393.aspx[^]To draw them using the mouse, just start the drawing on mouse down at the coordinates of the mouse pointer (set that as one corner of the object being...
3 Jul 2012 by Fun@learn
Check the sample application present with the library. They are very helpful to understand how to use, tweak the library.This library is excellent. Bitmap operations are not supported natively, but these guys did all the hard work to make it simpler for others.Major reason for this...
22 Jul 2012 by Farhan Ghumra
i have successfully developed my app, you can check Metro Paint[^]
15 Sep 2012 by Adam David Hill
Just a quick off-the-cuff idea, but have you tried just wrapping a TextBlock inside a ViewBox? I don't have access to VS at the moment to try, but I imagine that would scale it automatically for you with essentially no special code.Apologies if I've missed something.
15 Sep 2012 by Kenneth Haugland
Can you use this:TextBox myText = new TextBox();Rect textRext = myText.GetRectFromCharacterIndex(myText.Text.Length);http://blogs.microsoft.co.il/blogs/tamir/archive/2007/03/12/Text-length-measurement_3F00_-It_2700_s-really-easy-with-WPF.aspx[^]
10 Mar 2013 by kaushal joshi
Can any one tell me full code of draw a rectangle in webpage using asp.net c#. But i don't want to use bitmap image here. I need a simple webpage using c# asp.net in which only one rectangle should be there but without using bitmap image. Please do not use this:Bitmap bmp = new Bitmap(width,...
22 Mar 2013 by Dheeraj Singh Bhadoria
This Artical shows that how we can change the color of any image throw Bitmap
8 Apr 2013 by Sergey Alexandrovich Kryukov
This looks nothing more than 7 circles of the same size, which can be drawn using System.Drawing.Graphics.DrawEllipse:http://msdn.microsoft.com/en-us/library/a3fd63x2.aspx[^].You might see some problem in clipping of the lines by the round area. One of the method to achieve that is using...
24 May 2013 by wcb2@cornell.edu
I am having a problem drawing in the titlebar and border in Windows 7. The code below works fine in XP, but fails in Windows 7. Interestingly, if I place this code into a form and inherit it from another form, I can see the graphics drawing at design time. But when I run the app and display...
31 Jul 2014 by Sergey Alexandrovich Kryukov
The best and most reasonable way to do it is to use HTML5 Canvas feature: http://en.wikipedia.org/wiki/Html5_canvas[^].It will take considerable effort, but what you can do is quite...
19 Dec 2013 by nuke_infer
you can use the openGL platform.on visual studio or dev++ by allying the relevant .dll file and .lib file inserting.this url will help to you how to config the openGL in visual studio and same thing can apply if you are using the Dev++...
22 Apr 2014 by OriginalGriff
No, this is your homework, and you are expected to do it yourself, not get marked on what we do! :laugh:Drawing in Winforms is easy: just handle the Paint event for a Form or Panel, and use the supplied Graphics context.For example, this will draw a Green Rectangle overlapping a Red...
25 Jun 2014 by OriginalGriff
Start here: Bmp.Save(str1 & "\" & str2, Imaging.ImageFormat.Jpeg)Don't use Imaging.ImageFormat.Jpeg - it's a lossy compression technique and that means that it "throws away" information ion order to save space every single time you save it. The chance are, this is the source of your...
25 Aug 2014 by User 1234567
I need to draw a cross shape in android, i have fixed set of points to draw, Path path = new Path(); path.moveTo(133.133f, 45.7109f); path.lineTo(154.307f, 24.5363f); path.lineTo(175.482f,...
25 Aug 2014 by Fredrik Bornander
Use a scale Transform;Matrix matrix = new Matrix();matrixsetScale(2.0f, 2.0f);// path is your pathpath.transform(matrix); Or, if you want to scale around the center of the path;Matrix matrix = new Matrix();RectF boundingBox = new RectF();path.computeBounds(boundingBox,...
31 Aug 2015 by DanBecause
I can't say I entirely understand what you mean by "really change the pathpoints", but the Transform property on the Geometry will scale the Geometry before it is rendered and the Geometry will be rendered as though it were the scaled size (not a zoomed version of the original size). So, for...
6 Oct 2015 by Member 4385570
https://msdn.microsoft.com/en-us/library/k0fsyd4e(v=vs.110).aspx
27 Mar 2016 by Richard MacCutchan
You can use Windows GDI[^] to draw lines, curves etc. See Win32 Programming - FunctionX[^] for some useful tutorials.
4 May 2018 by Wendelius
There's a very nice conversation at c# - Fastest API for rendering text in Windows Forms? - Stack Overflow[^]
3 Aug 2018 by Richard MacCutchan
If you draw objects outside of the function that responds to the WM_PAINT message, then it will not work. As soon as the dialog is shown it will erase the background and redraw all controls in the resource. You should add the rectangle into your resource settings.
23 May 2019 by Richard MacCutchan
You should do all your painting/drawing to the screen in the function that handles the WM_PAINT message. Each time this function is called it should redraw all the shapes. When a shape is deleted you just remove it from the list of items to draw, and then call InvalidateRect to force a repaint...
19 Sep 2020 by Patrice T
your code is very simple minded, and it is bad. Quote: i use Timer which redraws the digits every 100 milliseconds. A simple test can divide by 10 the workload of redraw: if (LastTime != NewTime) { redrawClock(); LastTime = NewTime; } ...
20 Apr 2021 by Patrice T
Not really a programming question, more like geometry. Quote: How Can I see if 2 or more circels intersect or touching each other? Each circle is inside a rectangle, if both rectangle don't touch, circles don't touch. if rectangles touch, you...
20 Apr 2021 by OriginalGriff
Don't even check the rectangle: get the value of the distance between circle centres and compare that to the sum of the diameters. If it's less then they overlap, if it's equal then they touch, if it's greater they are separate. And it's easy to...
17 Aug 2011 by joe628aa
Hi There!I'm trying to draw non rectangular 2D shapes (polygons, ellipses) with open gl es in .net cf, which are textured with gradients. I thought that i could create the gradient by drawing a rectangle with its vertices colored and than use that rectangle as a texture on the actual shapes....
17 Aug 2011 by Anthony Mushrow
This[^] NeHe article (among other things) shows you how to render to a texture. The basic procedure is to set the viewport to the size of the texture then render whatever you need, and finally to copy your screen buffer to the texture using glCopyTexImage2D.If you need to update the texture...
18 Aug 2011 by joe628aa
Thank you for the answer, I'll try it out.
13 Sep 2011 by david94x
Hello everyone.I'm programming a tool that given a section (eg 16 x 16), drawings of characters from an image, but I can not, because everything that I found on the Internet, draw the form. Can anyone help me?This is the code that I did, but that does not work.Thanks in advance:) ...
15 Dec 2011 by Harish Kumar Bansal
Hi,I am developing a program. In this, i have a form with some controls like Button and Labels on the form. Now i draw a line on the form using DrawLine() method but this line appears in the backgrounds of all the controls like labels and Buttons. I want to draw line, above all the...
5 Jan 2012 by Member 8456258
Hello AllI have an Image viewer that displays an image. I want to draw a rectangle using the mouse over the image and get the x and y coordinates of the rectangle (X1, X2, Y1, and Y2). I will use these coordinates to create a search region and find the max and min values in an array that...
5 Jan 2012 by Sergey Alexandrovich Kryukov
I reported this question as "Unclear or Incomplete" and asked you: so, what's the problem? Just do it.There is one detail in the question that makes me think this is not so easy for you: overlay. Probably, you had some experience working with DirectX, that's why you think this is difficult....
6 Jan 2012 by CoolC22
I am currently writing on a program in Vb.net where I need certain regions or certain pixels of an image to be set transparent. I am not looking for setting a similar color in an image transparent, but specific pixels or regions in the image to be set transparent.Here's the code I tryed, but...
6 Jan 2012 by Member 8456258
Thanks for the pointers and help:Here is my finished code and it works. You place the mouse anywhere on the canvas hold mouse down and drag to create the rectangle. It could use some more improvement to drag and create the rectangle in any direction.XAML:
6 Jan 2012 by thams
HiActually painting with Transparant brush will not draw/overwrite any thing.To get the desired result you need to clear the pixels using the setpixel method.Here I've just cleared the pixels using the rectangle (which you've given as 4x4). Imports System.DrawingPublic Class...
26 Apr 2012 by StephanGumpert
I have a size of real rectangle in real life that I want Draw in a picturebox to scale.In the old days (VB6 Days) I would get the Width if the picture box and divide it by the size of the real rectangle to the X Scale. I would repeat this for Y also.The just procedure to draw retangle...
26 Jun 2012 by Sergey Alexandrovich Kryukov
[In response to follow-up discussion:]So, are you saying you could not find appropriate articles in MSDN? First, how about other than MSDN? What's wrong about this one:http://www.c-sharpcorner.com/UploadFile/65fc13/drawing-features-in-windows-8-metro-style-apps/[^]?As to MSDN, please...
3 Oct 2012 by Member 1441836
Hello to all,so this may sound a little weird question but i looked for it and could not found any helpful information.I would like to draw a Tree or Hierarchical diagram in Visual Studio (C#). I have an XML file where i have parent and child nodes. I would read the xml and for each node...
3 Oct 2012 by austinbox
Hello,Your question seems a bit vague but interesting, I would recommend using a treeview becuase it supports nodes and images like you said. //First lets read the xml.. List parents = new List(); List nodes = new...
7 Oct 2012 by Clifford Nelson
This is not straignt forward. I am not sure what you really want, but if you want to page from one to the other I would suggest using a scroll bar with a pane and replacing the image in the window with the correct page. If you are willing to just scroll, I would put the pages into a grid, and...
14 Oct 2012 by MarkGeologist
Thanks for the Reply, and apologies for my own delay.I will give your suggestion a try and see what results. I can see this is not so straight forward.For clarification, a web page is a better example. Smooth scrolling single document. but can significantly vary in length. ie if the top...
22 Oct 2012 by RafagaX
Probably a bit late, but you may (or others) find Drawing Library for Modern UI useful, it's a replacement for System.Drawing namespace that draws on top of a Canvas and provides a GDI+ like API.
5 Nov 2012 by govindaAlwani
I am bit confused how to calculate dx and dy in sobel edge detection method ....I googled it and i found that.......public class SobelEdgeDetector : ImageFilter { private Color grayscale(Color cr) { return Color.FromArgb(cr.A,...
11 Nov 2012 by YvesDaoust
You can use the coefficients from this source to compute dx and dy: http://www.cim.mcgill.ca/~image529/TA529/Image529_99/assignments/edge_detection/references/sobel.htm[^]
13 Nov 2012 by Olivier Levrey
Hi everyone,I'd like to reference a Path as a resource and display it several times in a control but there's something I don't understand. Here is my XAML code:
14 Nov 2012 by Olivier Levrey
OK I found by myself. Instead of declaring a Path object as a resource, I declared a Style for my paths. Then I created 2 paths and applied the style on them.For those who might be interested, here is the code:
24 Nov 2012 by anssary2010
How to show your System.Drawing.Color palette
28 Nov 2012 by Sergey Alexandrovich Kryukov
You heavily misuse Graphics. In principle, in some cases it's possible to do what you are doing, but you cannot expect that such rendering will be shown permanently. You really should not create and instance of System.Windows.Graphics, you should handle System.Windows.Control.Paint event or...
29 Nov 2012 by marcel zol
How to draw a rectangle in any direction? This code works only if you draw from top left corner and drag to the lover right corner.in mouseup event:r = new Bitmap(f1.pictureBox4.Image); gra = Graphics.FromImage(r); Pen p = new...
30 Nov 2012 by Zaf Khan
We used to use PSET (pixel set) command on a picturebox in VB2.I dont know if that command is still available in a picturebox object but its is pretty basic so I shuold assume its still there.As far as i can remember the command used go something...
8 Dec 2012 by Zaf Khan
Look at this sample i didhttp://www.codeproject.com/Questions/505546/howplustoplusdrawplusstraightpluslineplushorizonta">On this websiteits not in C++ but it shouldn't be too difficult to port
11 Dec 2012 by imran.mm7
Dear all, I have a very large xml file. In this file i have various data. I am using linQ to collect the particular information. I would like to present this information in a graph form (not the tree view control). This graph would simple contains data (parents) as circles or rectables and...
12 Dec 2012 by Kuthuparakkal
Trysomething like this:Maani Chart Implementation Simplified for ASP.NET Applications[^]
12 Dec 2012 by imran.mm7
Thank you for the link, but as i asked in my question. I need to draw it in a tree shape ...not chart..i already used Microsoft chart control to render data in charts..but now my interest is to render data in graph form..hopefully that clarifies my question..greetings
10 Mar 2013 by Asim Mahmood
http://stackoverflow.com/questions/8475232/draw-and-fill-a-simple-rectangle-in-c-sharp[^][]http://stackoverflow.com/questions/15295193/how-can-i-draw-a-rectangle-on-webpage-using-asp-net-with-c-sharp[^][]http://msdn.microsoft.com/en-us/library/system.drawing.rectangle.aspx[^][]
18 Mar 2013 by Abhinav_Sharma
Hi friends,Is there a way to draw tables dynamically(just like MS word 2007)in WPF using drawing visual class.For Eg. IN MS word User Select the no. of Rows and columns using Table Tab and as a result tables get created. Can the Same be implemented in wpfOr How to create tables...
27 Mar 2013 by Abhinav_Sharma
I am currently working on a custom canvas and in that i have to add a table,So i thought dataGrid would be fine. SO i Want to create a "Table" from "Datagrid" by which user can add a table to the canvas at runtime.Till now, I have tried to Populate DataGrid With a list and succeded.How...
27 Mar 2013 by Maciej Los
Some useful information and examples are here:http://msdn.microsoft.com/en-us/library/ms610560%28v=vs.85%29.aspx[^]http://msdn.microsoft.com/en-us/library/ms771480%28v=vs.85%29.aspx[^]http://www.c-sharpcorner.com/uploadfile/mahesh/gridview-in-wpf/[^]The New WPF GridView Customized - 1 of...
28 Mar 2013 by kastriotlimani
Hi, i am a beginner at coding, and i am making a little game where a character is capturing some dots generated randomly.Now i need each dot to be an image (same image for all), but i cant find out how to do it.This is a piece of what I did:Rectangle[] rects;rects = new...
18 Apr 2013 by Victor Snow
Hello! I'm working on one of my first apps for windows store and are over all quite new with programming(1 year of experience). Right now I want to make a small app with the ability to paint in. Something in the style of the old windows paint, but more simple. I have been looking at SVG and...
24 May 2013 by Sergey Alexandrovich Kryukov
As I say, the question is interesting, but going in for resolving it I think is too boring. :-)My idea is: the effects you can achieve in best case are very limiting anyway, but by using such effects you badly sacrifice platform compatibility of your code.The usual (and I think,...
16 Jun 2013 by Mohamed Sayed
i need your help for adding Rectangle,Circle and Ellipse options to my mini-paint app project,but i need all this on mouse event, i searched every where but most of sites give specific dimensions so I'm failed to get rectangle option to work :(i add save option to save the drawn pic to bmp...
22 Jun 2013 by Member 9522119
I try "pictureBox1.Image = img;" but it dosent workCannot implicitly convert type 'System.Windows.Controls.Image' to 'System.Drawing.Image'This (Image img = new Image) = System.Windows.Controls.Image private void button4_Click(object sender, EventArgs e){ ...
22 Jun 2013 by Ron Beyer
They are not immediately compatible, meaning they cannot be cast from one to the other. This Link[^] has some example code on how to convert from one to the other.
9 Jul 2013 by p.shakthivel
I am able to draw on view but when I set background to my view, I am unable to paint on background imgae please help me
10 Jul 2013 by Sergey Alexandrovich Kryukov
It depends on the drawing library you are using. You should always tag it.Please see the relevant methods here: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^].If you use WPF, the approach should be different:...
18 Jul 2013 by Nerd of C++
Hello,When is the DrawItem function called when I am creating a ownerdrawn control?Should I call it explicitly or it will be called whenever I call the "Create" function to create the control?Thanks.
18 Jul 2013 by CPallini
Usually you don't call explicitely it. See "WM_DRAWITEM message" at MSDN[^].
2 Sep 2013 by Nelek
http://www.google.de/#q=c%23%2...
12 Sep 2013 by Bilaal John S
Please checkhttp://social.msdn.microsoft.com/Forums/windowsapps/en-US/141afaf4-9638-4387-9f4e-8bfef1da62f7/how-to-use-svg-images-in-windows-8-store-apps-cxamlhttp://stackoverflow.com/questions/13788934/using-a-svg-file-for-a-background-for-a-windows-store-app-metrothanks,Bilaal
12 Sep 2013 by Bilaal John S
This link will help youhttp://stackoverflow.com/questions/4978723/grid-table-in-wpfThanks,Bilaal
19 Oct 2013 by Member 10257531
if the pages is more than 1 and i press a button the print preview don't stop generating print preview it will only stop if press the cancel button, then it will display the table with more than 1 pages but the data inside the tables is just the same. how can i solve this print preview problem...
19 Nov 2013 by Member 10412342
I saw that problem appear when I attempted to correct a printpreview issue with page numbering that continued vs. restarting when printing the hardcopy. In case this helps you, in DrawRows function, I needed to reset PageNumber and mColumnPoints. CurrentRow = 0 ...
19 Dec 2013 by Domus1919
Hi, I'm using OpenCV on Visual C++ 2010 for elaborate a set of images. But now I need to draw a set of 3d points (x,y,z) in a 3d space, because I need to have a feedback of how these points are allocated in 3d space. I don't need to do anything exceptional, so what would you advise me...
17 Feb 2014 by DFaeuster
Hey Folks,I'm facing an annoying problem that drives me nuts.On my CView-derived view I placed an ActiveX Control that consists of some buttons - nothing fancy or special. At the beginning it is shown correctly but after the OnUpdate()-method of the view the Control is not shown anymore...
18 Feb 2014 by bling
This *usually* means the containing window is processing the WM_ERASEBKGND windows message. If the Active-X control draws it's own background - having the containing window do this is a waste and also causes flicker. Override this message to return a non-zero value (eg. 1) to suppress this...