.net - Why Is Graphics.DrawLine Drawing A Wedge Shape
Nov 4, 2011
I am trying to draw a bus route as a simple sequence of lines. Nothing fancy. But instead of lines, I'm getting wedges. Initially I was fine with this, because the wedges sortof look like arrows and always face towards the second point. But now I want to improve the look, and the wedges are becoming a big problem.
My suspicion is some sort of floating-point issue due to the graphics transform (lat/lons are fed in and the transform turns them into x/y on the bitmap [assuming lat/lon is euclidean is accurate enough for my purposes], so the scaling is several orders of magnitude).
Screenshot:
It actually kind of looks like the line was split into two triangles but only one of them was drawn.
Relevant Code (note: drawing is done asynchronously, which is why I'm creating a bitmap):
'-- Creating the transform --'
Dim bitmap = New Bitmap(Math.Max(1, PictureBox1.Width), Math.Max(1, PictureBox1.Height))
Dim g = Graphics.FromImage(bitmap)
[Code].....
Using DrawLines instead of DrawLine solves the issue (but why?) Increasing the pen thickness makes the issue go away (but the lines are too thick) Zooming out (increasing lat/lon view window) makes the issue go away, eventually (but I want to zoom in!)
View 2 Replies
ADVERTISEMENT
Oct 13, 2008
Is there any way to have 2d graphics that gets made by user through manual dimensions input be bound to a text box?
Is there any way to take position 1000,600 and make that zero? Can we make graphics by inputting only the next co-ordinate and have the pc automatically draw a line from last point?
Also, whats the difference between drawline and draw path? How can I get the shape to remain on screen when I toggle between pages?
View 9 Replies
Aug 14, 2009
drawing text on a window which is not the current form's window.I remember doing this in Win32 api with getwindowdc(handle) to obtain a DC for the Window, then textout() on the DC.
View 2 Replies
Jun 6, 2011
i am working on a virtual make-up software and the only thing i lack to totally finish it is the lipstick part. is there a way that i can trace the edges of the lips of the picture that im editing and fill its insides with colors from a colordialog that will serve as if it applied a lipstick. just like what they have on jkiwi that users will jut trace the edges of the lips and then the color will automatically be filled out and it can be changed by choosing a color in a dialogbox.
View 1 Replies
May 23, 2009
Is it possible to convert an object form System.Drawing.Graphics to System.Drawing.Image?
View 4 Replies
Jul 25, 2009
Ok..I think it's very simple but I'm still a begineerI'll try to make it clear I need to draw a rectangle when I click on the button..what is the required code?
Quote:
Public Class Form1
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
[code].....
View 1 Replies
Jan 3, 2010
here is my problem i am making a blockbusters game and have come across a problem where 2 picture boxes overlap each other which i dont want so i need to make a picture box or a button into a hexagon shape so they wont overlap
View 2 Replies
Jan 20, 2010
I have a System.Drawing.Graphics g, which draw something in a PictureBox. Now I want to export this pGraphics to a new System.DrawingImage pImage (or Bitmap). But how?
Dim pImage As Bitmap
Dim g As Graphics
g = Graphics.FromImage(b)
[Code].....
View 9 Replies
Mar 10, 2010
I have two graphics I'm trying to superimpose into one, then display in a DataGridViewImage cell...The Value property of a DataGridViewImage is an Image type.
Dim Image1 As System.Drawing.Image = imgl_Imagelist1.Images(0)
Dim Image2 As New Bitmap(imgl_ImageList2.Images(0))
Dim DualGraphic As Graphics = Graphics.FromImage(Image1)
[code].....
View 3 Replies
Feb 20, 2009
I have been trying to draw spirals in vb.net. Here's a link to the formula [URL]. here's what I was trying to do. The code below is just drawing points which I was later going to edit to connect from point to point as soon as i got the spiral function working.
Function Draw()
Dim iImageCenterPointH As Integer = pbOut.Height / 2
Dim iImageCenterPointW As Integer = pbOut.Width / 2
Dim iCircleSpace As Integer = 10
[Code] .....
I am not 100% the output is matching the formula here's what I am getting atm ...
View 7 Replies
Oct 21, 2010
I know this is probably not going to be simple, I tried searching around, but couldn't find anything. I am using some code to 'draw' text in a custom format to a panel with a custom bitmapped region (custom shape).Here is the code that writes the text inside a specified area:
g = LeftControlPanelV2.Panel1.CreateGraphics
Using fnt As New Font(New FontFamily("Arial"), 9, FontStyle.Regular, GraphicsUnit.Point)
Dim sf As StringFormat = StringFormat.GenericDefault
sf.Trimming = StringTrimming.EllipsisWord
[code]....
Obviously the text is not really located on the panel, but looks like it as it's drawn on top of the panel. So, when the panel or form that the panel is attached to moves, I lose the text. I though I could just call back to writing the text when the panel/form arrives at the correct place, while clunky, it works to a degree. I was hoping there was a better way of doing this, so that the text doesn't disappear when moving controls and I don't have to make repeated calls to the same drawing text over and over and over...
Edit: Should probably add that there will be 5 different panels each with their own custom drawn text, and all 5 need to move at the same time...
View 2 Replies
Aug 3, 2010
I have been researching for a while, and now am converting my project from using forms to do transparencies to just drawing the images. At first, I thought picturebox's could be used, but can't figure out how to do transparencies on those, so I settled for drawing images. Here is what I am using: [Code] Now, I know these are not controls, but is there any possible way to make these drawn images have a click-able event fire?
View 4 Replies
Jul 15, 2010
Rather than create a Form and use Graphics generated via the CreateGraphics Method, how does a System.Drawing.Graphics Object get built?
View 16 Replies
Sep 13, 2009
I have been looking through the code bank and i cant find anything that is helping me with my problem what i have is a print button that when clicked it goes to my print preview page, then i can print the file. i have got all the other controls on my page to display correctly using this example
e.Graphics.DrawString(sType, New Font("Arial", 10, FontStyle.Underline), Brushes.Black, 110, 650)
but how can i get my ListView header and content to preview on the page as well. my listView has 5 columns and i am using the PrintDocument control.
View 10 Replies
Apr 9, 2011
I have been having problems getting a vb.net app to have the same responsiveness to drawing and manipulating graphics as I had with vb6 and the API. In my journeys here at this forum and elsewhere, I understand that GDI+ is pretty much a gonner, and that other avenues should be explored. For instance, I have been doing my initial research into WPF and it seems that maybe it would be a more natural shift from GDI+ than moving to DirectX or OpenGL.
View 8 Replies
Nov 23, 2011
I have 1 image in picturebox. Now I draw some rectangles. I'm trying clear the image (only rectangles and left the image) without success.
Private Sub btnImageSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImageSelection.Click
Dim intImages As Integer = 0
Dim intImagesLine As Integer = 0
Dim intImagesColune As Integer = 0
picImage.Image = PictureBox1.Image
[Code] .....
The cycles for is for show the rectangules and works fine. but
i.Clear(Color.Blue)
The image is clear but the rectangles are showed and then unshowed.
View 19 Replies
Jun 7, 2011
I need to make a basic drawing program in VB that can do three things:
"Draw" with a brush of some sort
Clear the screen
Perform a flood-fill (paintbucket action)
I decided to do the first two tasks first, and got them to work, but the third task completely eludes me. Every way I try seems to pile on exceptions, and every flood-fill algorithm I find seems to require a bitmap, rather than a Graphics() object. Is there any way to accomplish a flood-fill using a Graphics object, or must I restart the project using a bitmap?
Source code for reference:
CODE:
View 2 Replies
Dec 30, 2010
How can I increase the pixel size of a Graphics like in an image-editor?Goldfish64 - Please remember to mark any replies as answers if they help and unmark them if they provide no help.
View 4 Replies
Dec 18, 2011
I am drawing a bunch of shapes on a form and I want to relegate some of these to a subroutine other than Form1_Paint().The form has the DoubleBuffered property set to TRUE.All the shapes that are drawn by an external sub get overwritten:Code:
[Code]...
View 3 Replies
Feb 2, 2012
I have several picture boxes on a form (frmMain).My question is, how do I paint a point on a particular picture box at the location specified by the coordinates of the current mouse position? The snippet below shows defining some canvases and pens. But I'm not sure how to capture the mouse position when the mouse is over a particular picture box and how to paint the actual point at that location.[code]
View 3 Replies
Jan 18, 2011
IGraphics and drawing and invalidating thing.I have improved, that I can tell. I won't explain everything, so here's the essential:Technically, my application will let you draw a rectangle on the form. You click, drag, and boom, a red rectangle is there. This rectangle will disappear when you start drawing another.I got that working.But my problem is performance. You see, obviously I have to update, invalidate and paint my rectangle every time the mouse moves while it is in "drawing mode". I do that every time the mouse's position changes.And that is quite a big deal. Every time the mouse's position changes? That's a lot of invalidations and redraws for a decently-sized rectangle!I thought of skipping some mouse movement, like only update every 5 coordinates moved or something. But that would render my goal quite inaccurate.I already invalidate only the regions necessary, that I can tell.
View 5 Replies
Jul 25, 2009
I'm trying to make a custom combobox from scratch that multiple instances will share the listbox that holds the data on. I'm trying to draw the button face manually using GraphicsPaths and pens and brushes, but I'm having a few issues with it:
1. How do you draw that down arrow glyph in a way that doesn't look like a two-year-old sneezed on it? I'm having problems with the shape looking like the traditional one.
2. How do you position the listbox that contains the data in such a way that isn't bound by the containing form's render window?
3. I've tried to make the background look different when it has focus, but the OnPaint seems to think it always has focus and always makes the background the "focused control" background.
View 2 Replies
Jul 17, 2008
Im using VB 2005 express edition. Im trying to draw rubber band lines and rectangles using controls like buttons in one form. My problem is, i did the rubberband lines and rectangles on diff forms.Here's the snippet code for rubberband rectangle:
Code:
Private Sub MyDrawReversibleRectangle(ByVal p1 As Point, ByVal p2 As Point, ByVal dashed As Boolean)
[code].....
View 14 Replies
Jun 4, 2009
I am coding a reversi game for my computer programming class and I need help with something. I have a list of all the systems.drawing.graphics brushes in a Combobox and I want the user to be able to pick their color. So I have the list of colors I just need to make it so I can set the color the user picks to the brush that is for his team I guess you would say.
[Code]...
View 3 Replies
May 29, 2009
This little experiment was a test prompted by a previous thread to learn to work in a graphics object, then paint everything later to a picturebox (later, will be looking at building own custom control for the display), and save out the bitmap to a file on the HD.But weird things happen here. Nothing will display in the picturebox, and the saved bitmap is just a black box.The only partial success I had was replacing: e.Graphics.DrawImage(MyBitmap, 0, 0)
with,
PictureBox1.image = MyBitmap
inside the paint event handler, but that caused infinite recursion of the paint event. But at least I could see parts of the graphic for a fraction of a second before it was wiped clean, every time I clicked the "Go_cmd" button. But what is weird is that this partial success showed that the graphics object was copying successfully over to the bitmap image (because I could briefly see parts of it in the picturebox, but the saved file would still come out black, even though it was based on the same bitmap!The code is as follows.Above the form1 class
Imports System.Drawing.Imaging
The single declaration:
Public MyBitmap As Bitmap
The form_load procedure:[ code].....
The code in the version shown above would not even show a brief moment of the graphics in the picturebox, and the saved .bmp file is just a filled black box.
View 5 Replies
May 17, 2010
I have a Form1 where i can add usercontrols during runtime. I draw their appereance in the OnPaint event using the GDI+ engine. The greate part is that i want to be able to resize these images during runtime wich goes pretty well now cause i draw points in percentage of the control. Unfortunetly it is very difficult to draw nice images/drawings ect with the GDI+ engine. Is there any other way in doing this?
[Code]....
View 7 Replies
Feb 9, 2009
Well im just upgrading from VB6 and i was able to paint images to the background of a form. The same method does not seem to work in VB 2008. Is there a way i can draw/paint images to the background of my form?
View 7 Replies
Jun 8, 2010
I'm just getting started, and it's as simple as that: I need guidance to draw a rectangle or place a dot or a point on Form1, in VB 2008 Express. I knew how in VB6 -- let's build on that.
View 3 Replies
Jan 14, 2012
I am drawing a circle, of let's say 300 pixels diameter. I want to draw a triangle, with the top of it being at New Point(diameter / 2, 0). How could I get the other 2 points of the triangle? If possible, how could i get the 3 points of a triangle rotated by x degrees?
View 1 Replies
May 26, 2012
Problem1: I have a picturebox on a form. I have also managed to draw several PNG files with transparency onto the picturebox (see below). However, If I move the form outside the border and move it back, the image is gone. My source so far:
Dim k1 As New Bitmap(My.Resources.image1)
Dim k2 As New Bitmap(My.Resources.image2)
Dim drawMe As Graphics = PictureBox1.CreateGraphics
Dim bgcolor As Color = Color.FromArgb(128, 128, 128)
drawMe.Clear(bgcolor)
[Code]...
View 10 Replies