|
-
Feb 21st, 2004, 12:48 PM
#1
Thread Starter
New Member
Whats wrong with this?
This is the error message given when i try and draw a rectangle
An unhandled exception of type 'System.ArgumentException' occurred in system.drawing.dll
Additional information: Invalid parameter used.
I get an error from this code:
Private Sub picBoard_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picImage.MouseMove
If isDragging Then
Dim gr As Graphics = picImage.CreateGraphics
gr.Clear(picImage.BackColor)
Dim rect As New Rectangle(startX, startY, e.X - startX, e.Y - startY)
gr.DrawRectangle(Pens.Red, rect)
gr.FillRectangle(Brushes.Transparent, rect)
Dim bmpCropped As New Bitmap(e.X - startX, e.Y - startY)
Dim grBitmap As Graphics = Graphics.FromImage(bmpCropped)
grBitmap.DrawImage(picImage.Image, 0, 0, rect, _
GraphicsUnit.Pixel)
picImage.Image = bmpCropped
picImage.SizeMode = PictureBoxSizeMode.Normal
gr.Dispose()
End If
End Sub
This is supposed to crop the image from the rectangle drawn.
the error is from this line of code because it accepts invalid inputs i think.
Dim bmpCropped As New Bitmap(e.X - startX, e.Y - startY)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|