Parameter Is Not Valid Error While Drawing A Rectangle

Jun 26, 2011

I have made a program that lets you select an area of a picture and then crop it, I am having problems while drawing the rectangle that shows which area will be cropped, following is my code.

[CODE].............

This is declaration of all the variables that I am using.

[CODE].............

Over here I send the graphics handle of the "canvas" control (which is just a picturebox) to a higher level, so I can use it later.

[CODE].............

Over here I get the starting position for my rectangle

[CODE].............

This part is supposed to draw the rectangle, as I am moving the mouse over the Canvas control, but I get an error where the rectangle is being drawn, I originally thought that the problem might have been with the fact that as soon as I begin moving the mouse, the CropWidth and CropHeight variables are at zero, and that is causing the invalid input error. So I made it that it would not draw the rectangle until it reached a minimum size of 4 x 4 pixels but it still does not fix the error, I debugged to see if there was a problem with the values of the variables, but they all seemed fine, I even tries doing this CanvasGraphics.DrawRectangle(Pens.Red, 20, 20, 20, 20) so as to eliminate the factor of the wrong values, but still the same error.

View 3 Replies


ADVERTISEMENT

Drawing Rectangle Inside Another Rectangle?

Jul 26, 2009

I'M creating a kind of photo viewer, and I cannot figure out how to orient the scroll buttons with the photos I want to draw because they all are different sizes.This is really hard to explain so please ask questions if you don't understand.I'M thinking if i could draw every photo on a single rectangle and then the scroll bars will position that rectangle up or down. but is there a way to make a rectangle inside another one so it only shows inside that rectangle?

View 10 Replies

Error : Parameter Is Not Valid

May 14, 2012

Dim data As Byte() = DirectCast(sdr.Item("Image"), Byte())
Dim ms As New System.IO.MemoryStream(CType(sdr.Item("Image"), Byte()))
PictureBox2.Image = Image.FromStream(ms)

After reading many forums and trying the different examples, when I try and load my image from the database I get the "Parameter is not Valid" error.Im using VB 2010, SQL Server 2008 R2, and the data type is Image. I do not have access to the source code that is used to save the picture to the database, just access to tthe data in the db.The code I have included is the code I use to retrieve images from my db which stores the pictures as Image.

View 2 Replies

Error Parameter Is Not Valid

Aug 17, 2010

STEP1--image data is sending by a vehicle tracking unit.using a socket application i am tracing that data.the data from the vehicle tracking unit is not in a decimal format.image data coming from socket containing lot of special type of characters. so i am converting this image information to hex format using the code below.

Private Function Data_Asc_Hex(ByRef Data As String) As String On Error Resume Next 'first take each charcter using substring. 'then convert character into ascii. 'then convert ascii value into Hex Format Dim sValue As String Dim sHex As String = ""

[code]....

View 14 Replies

Error - System.ArgumentException Was Unhandled. Parameter Is Not Valid

Feb 28, 2010

In this screen I want to let the user decide which elements are on shown on a label. When I hit the update button (BDUpdate_Click; see below), it first checks whether the Barcode sample text is empty. Afterwards I want to invole the refresh of the label preview. The strange thing is that the first time it works fine, but when I alter the sample text and hit the button again, I get the Error "System.ArgumentException was unhandled. Parameter is not valid." The error points to the DrawSting function in the LabelPreview_Paint Sub

Dim BarcodeLabelUpdate As Boolean
Private Sub BDUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BDUpdate.Click
If BDBarcodeSample.Text = "" Then
MsgBox("Please enter a sample text", MsgBoxStyle.Information Or MsgBoxStyle.OkOnly, ProgramTitle)

[code]....

View 2 Replies

Error Occurred Creating Form - Parameter Not Valid

Jun 22, 2010

I am trying to run my program to test it. Actually I am trying to run second form to see it that its working properly or not. But it shows me error. First time I got this error message:
"Exception of type 'System.OutOfMemoryException' was thrown"
& second time I got this one
"An error occurred creating the form. See Exception.InnerException for details.
The error is: Parameter is not valid."
By the way my program has 25 forms.

View 2 Replies

IDE :: Image.FromStream(ms)----> Error "Parameter Is Not Valid?

Feb 11, 2007

have an OLE Object in my table, that may be jpg, doc, xml file.In case of jpg I'd like to show it (VS2005 Visual basic).I did next (not full code):Dim ms AsNew MemoryStream()Dimreader As OleDbDataReader = md.ExecuteReader(CommandBehavior.SequentialAccess )reader.Read()retval = reader.GetBytes(0, 0, outbyte, 0, bufferSize)ms.Write(outbyte, 0, retval)ms.Seek(0, SeekOrigin.Begin)curImage = Image.FromStream(ms)----> error "Parameter is not valid."I do not see the fault

View 3 Replies

Parameter Is Not Valid Error When Reading From An Image Property?

Apr 20, 2010

I am getting a "Parameter is not valid " error when reading a value from an Image property and I don't know why.

Writing to the property works just fine (MyControl.EditImage = PictureBox1.Image) .

Reading from the property causes an error (PictureBox1.Image = MyControl.EditImage )

The Property looks like:

Private mNewImage As Image
Public Property EditImage() As Image
Get

[Code]....

View 4 Replies

[2008] Images From DB To ImgList Error - Parameter Is Not Valid

Feb 13, 2009

I am trying to write a small app that will read images from an database to an image list. It does the first one, but then after that i get a "Parameter is not valid." exception ... see code below.

vb
Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "states.qmw")
Dim cm As New OleDb.OleDbCommand("Select * from tblStates", cn)
Dim rd As OleDb.OleDbDataReader

[code]....

View 1 Replies

Tetris - Error "ArgumentException Unhandled, Parameter Is Not Valid?

Mar 7, 2012

I'm trying to make a Tetris game in VB 2010. I am having some problems with a function I have written that draws new squares and fills them with the colour needed. Here are the details of the error:

System.ArgumentException was unhandled

Message=Parameter is not valid.
Source=System.Drawing
StackTrace:[code].....

The line g.DrawRectangle(Pens.Black, lngX, lngY, 24, 24) is highlighted as the error. 'g' is the graphics of the form and lngX and lngY are the predetermined coordinates of the shape as long variables.I have researched this error but I couldn't understand Microsoft's explanation, and no other threads applied to my case.

View 2 Replies

Drawing A Rectangle Around The Panel?

Apr 24, 2010

I have used this code to draw an rectangle around the panel

vb

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.PaintWith Panel1 e.Graphics.DrawRectangle(Pens.Gray, .Left - 1, .Top - 1, .Width + 1, .Height + 1) End WithEnd Sub

but when the form is resized the rectangle isnt drawn properly.The panel has Left,R,T,B anchor.

View 10 Replies

Some With Drawing With Rectangle Stucture?

Apr 12, 2009

i have a problem when I draw a rectangle the sides of the rectangle aren't the same width

I don't know what's wrong this a picture about the problem[URL].. and here is the code

Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class Form1

[Code]...

View 9 Replies

Drawing A Resizable Rectangle On Picturebox

May 26, 2010

I have try many different methods but still no avail.how to do this? As i found a good tutorial over

here where it create a resizable rectangle on a form. But what i want is on a picturebox with image.

View 7 Replies

Setting Rectangle Drawing Coordinates?

Oct 7, 2011

Okay, I've got a rectangle shape named Header and in the form class I Dim a new rectangle named DrawingRect. Here is the code that I used to set the location coordinates and size.

Dim DrawingRect As New Rectangle(Header.Size.Width - 18, Header.Size.Height - 17, 14, 14)

Whenever I run the program, however, it stops me and says "InvalidOperationException was unhandled". How do I get this to work?

View 3 Replies

Pass An Optional Parameter To A Function Of Type System.Drawing.Color - Error "Constant Expression Is Required"

Mar 22, 2012

I want to pass an optional parameter to a function of type System.Drawing.Color. The problem I am having is that when I declare the function it says "Constant expression is required" but I have tried variations of the following, including integers, full qualified indentifiers, even old vbWhite constants to no avail.

[Code]...

View 14 Replies

Drawing Rectangle Inside Ellipse At Runtime?

Jan 2, 2010

How to draw a rectangle inside an ellipse at runtime?

View 8 Replies

Loop Through Points In A System.drawing.rectangle?

Sep 6, 2010

Looking for something like:

dim rect as system.drawing.rectangle
For each point in rect
Debug.print(point.name, point.value)
Next

View 2 Replies

Drawing A Resizable Rectangle (by Edge/corner Dragging)?

Jul 19, 2003

I am trying to make a rectangle that can be resized by the userby clicking and dragging the edges/corners of the rectangleTypically, if the mouse enters the rectangle region, then smalladjustment boxes should appear at the corners of the rectangleand also at the middle of the rectangle's edges (to allow the userto drag and resize the rectangle). When the mouse leaves therectangle region, then the adjustment boxes should disappear.I have the code to draw the rectangle and to produce the smalladjustment boxes, but I'm not sure how to accomplish thedrag and resizing steps (or if it's even possible with the way mycode is written).

Code:Imports SystemImports System.DrawingImports System.Windows.Forms
Private bBlocking, bValidBox As Boolean Private pt1, pt3 As Point Private rectBox As Rectangle Private cornerRect1 As Rectangle Private cornerRect2 As

[code]....

View 10 Replies

Interface And Graphics :: Drawing A Rectangle Or A Point On A Form?

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

DrawLines Method - Run-time Error: "Parameter Is Not Valid"?

Dec 31, 2009

I've written the following code to draw a trajectory of points in my program:

Private intNumOfPoints As Integer = 0
Private PtTrajectory(intNumOfPoints) As Point[code]....

*Pos.X and Pos.Y are calculated in the other parts of my program. But, it has a run-time error: "Parameter is not valid".

View 7 Replies

Memory Stream To Image :Error "Parameter Is Not Valid"

Jun 9, 2011

Public Sub imageload(ByVal index As Integer, ByRef imagedescription() As String)
Dim da As New OleDbDataAdapter("Select Foto From Images where Photoindex = " & index & ";", Form1.baglanti)
Dim dt As New DataTable
Dim ms As New MemoryStream

[code]....

i was take "Parameter is not valid." error pff where is my mistake?

View 3 Replies

[2008] Error: InvalidArgument=Value Of '6' Is Not Valid For 'index'. Parameter Name: Index

Mar 5, 2009

I've got the web browser with tabs in all working fine, but there's one bug, i can add tabs, delete em, etc.. but when i delete a tab then go to create a new tab, it gives me the error: InvalidArgument=Value of '6' is not valid for 'index'. Parameter name: index '6' is the number of tabs i had open.Here's the bit of code i use to create the tabs with the browser in it:

vbcode

Dim browse As New WebBrowser
browse.Name = "b1"
browse.Dock = DockStyle.Fill

[code]....

View 2 Replies

VS 2008 - Drawing A Rectangle Snapped To A Grid By Getting Start Point

Dec 27, 2009

I'm drawing a rectangle snapped to a grid by getting the start point(Mouse down e.location) and the end point(mouseup(e.location). The coding I'm having trouble with is having the program determine which way to draw the rectangle(where the location should be, and the height and width.) Now, this would be extremely simple if the user started their rectangle from the top left corner and ended it in the bottom right every time. But you need to be able to drag from all angles. So does anyone have some code lying around that I could look at so I could actually get my rectangles drawn right?

View 5 Replies

Error - "Parameter Is Not Valid"

Oct 10, 2010

I have been trying to learn vb.Net for about a year now, but with other work getting in the way, my progress forward is moving, but not as fast as I would like. So I am hung up on this issue which seems like it should be a no-brainer but it still does not make sense, and I can't find any clarification on it.

With the

With MyPen
.Color = Color.FromArgb(LineColorVALs(7, SearchIndex1, SearchIndex2))
.Width = LineWeights(7, SearchIndex1, SearchIndex2)
End With

The array "LineWeights()" is declared as Integer and the values of the indexes are correct. This leads to an integer value of "1" coming out of the array and into MyPen.Width.

The ".Color" line executes OK, but I get the error, "Parameter is not valid." at the ".Width" line. I have tried declaring LineWeights as Short, too, but same problem.

View 13 Replies

Interface And Graphics :: Making A Custom Class That Mocks The System.Drawing.Rectangle Class?

Jul 6, 2010

I'm making a custom class that mocks the System.Drawing.Rectangle class because the Rectangle class doesn't have a name property. I need a name property because I am adding all of my rectangles to a collection and I need a little more info stored than just their locale and size. So I changed the _onPaint event but nothing is working out when I run the program?

Public Class Rectanglar : Inherits UserControl
Public BackgroundColor As Color = Color.Blue
Public Sub New(ByVal name As String, ByVal XY As Point, ByVal Widthy As Integer, ByVal Heighty As Integer)

[code].....

View 5 Replies

Error: Operator '=' Is Not Defined For Types 'System.Drawing.Image' And 'System.Drawing.Bitmap'

Aug 17, 2009

With this line...

If PictureBox1.Image = My.Resources._2star Then

I get this error: Operator '=' is not defined for types 'System.Drawing.Image' and 'System.Drawing.Bitmap'.Is there another way to say = with images?

View 8 Replies

Parameter Is Not Valid Exception?

Mar 27, 2009

I get this error from my application, but not in the development environment (VS 2008). I created an installer package and have installed it on two different XP machines with no problem. However, on a Vista system when the application runs code to generate an image I get a "Parameter is not valid" exception. I have no clue what could be causing this given the circumstances. To generate the image I am creating a bitmap with a valid size and simply creating the graphic. Since I can't repoduce the error in VS I don't have a way to troubleshoot this.

View 7 Replies

Parameter Is Not Valid On Picture Box

Jan 15, 2012

I have a program with multiple forms. I have an upload picture from file form that shows a picture in a picture box when I choose it. However when i navigate away from that form and then return to it a large X appears in the picture box and wont leave. [code]...

View 2 Replies

VS 2005 Parameter Is Not Valid

Dec 25, 2009

I use following codes to display image from SQL Table's image field. But on this line

.Image = Image.FromStream(ms)

it shows this error message

Parameter is not valid.

[Code].....

View 1 Replies

Error Value Of Type System.Drawing.Image Cannot Be Converted To System.Drawing.Icon

Jan 21, 2010

Here is my favicon code

Dim oURL As Uri = New Uri(e.Uri.AbsoluteUri)
Dim favicon As Image
If oURL.HostNameType = UriHostNameType.Dns Then

[code]....

The error is Value of type System.Drawing.Image cannot be converted to System.Drawing.Icon Is it even possible to make the favicon be the icon of the form?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved