Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27412

Basic Graphics Logic Help

$
0
0
Hi,

I have been having a very hard time wrapping my head around drawing in vb.net

Here is what I am doing,

vb.net Code:
  1. Public Class Form1
  2.     Dim _Pen As Pen
  3.     Dim min As System.Drawing.Point = New Point(521, 211)
  4.     Dim max As System.Drawing.Point = New Point(1261, 1249)
  5.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  6.    
  7.         If max.X = 0 Then
  8.             Exit Sub
  9.         End If
  10.  
  11.         Dim Img As New Bitmap(max.X, max.Y)
  12.  
  13.         Dim g As Graphics = Graphics.FromImage(Img)
  14.  
  15.         g.Clear(Color.White)
  16.  
  17.  
  18.  
  19.         _Pen = New Pen(Brushes.LightBlue, 5)
  20.         _Pen.DashStyle = DashStyle.Dash
  21.  
  22.         g.DrawLine(_Pen, min.X, min.Y, max.X, max.Y)
  23.  
  24.  
  25.  
  26.         PictureBox1.Image = Img
  27.     End Sub
  28.  
  29. End Class

So I am creating a image that is 1261 x 1249 and then I draw on this image a line from the bottom to the top.

I then set this image to my picture box which has dimensions of 638 x 723. But the line never shows up or shows up at a random place. It is very furstrating lol.

Does my logic make sense?

Viewing all articles
Browse latest Browse all 27412

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>