TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Duane
NA
77
0
What's wrong with this code?
Jul 6 2012 8:17 PM
What's wrong with my code? I can't figure it out. The variables seem to be picking up the correct information, and yet the variable "bmp1" keeps spitting out an error in Debug: Parameter not valid. This is about as vague as it can be.
If you can't figure out what's wrong, maybe you can tell me what's
right
. This ought to take less time.LOL
'declare string to house entire path and name of final file.
Dim totalFileString As String
'match temporary bitmap against other similar bitmaps.
'if there is a match destroy temp file and do not save as new file with others.
'if no match, then save the temp file as a new file with next incremental numbers.
Private Sub btnMatch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnMatch.Click
Dim dir As New DirectoryInfo("C:\Documents and Settings\Owner\My Documents\Pentominos\")
Dim fileArr As FileInfo() = dir.GetFiles()
Dim fiInfo As FileInfo
For Each fiInfo In fileArr
Dim bmp1 As Bitmap = New Bitmap(fiInfo.Name)
For x As Integer = 0 To bmp1.Width - 1
For y As Integer = 0 To bmp1.Height - 1
If (bmp1.GetPixel(x, y) = bmp.GetPixel(x, y)) Then
MsgBox("Match. Nothing New.")
Exit Sub
End If
Next
Next
Next
'rotate 180 degrees, flip none
For Each fiInfo In fileArr
Dim bmp1 As Bitmap = New Bitmap(fiInfo.Name)
bmp1.RotateFlip(RotateFlipType.Rotate180FlipNone)
For x As Integer = 0 To bmp1.Width - 1
For y As Integer = 0 To bmp1.Height - 1
If (bmp1.GetPixel(x, y) = bmp.GetPixel(x, y)) Then
MsgBox("Match. Nothing New.")
Exit Sub
End If
Next
Next
Next
'rotate nothing, flip X
For Each fiInfo In fileArr
Dim bmp1 As Bitmap = New Bitmap(fiInfo.Name)
bmp1.RotateFlip(RotateFlipType.RotateNoneFlipX)
For x As Integer = 0 To bmp1.Width - 1
For y As Integer = 0 To bmp1.Height - 1
If (bmp1.GetPixel(x, y) = bmp.GetPixel(x, y)) Then
MsgBox("Match. Nothing New.")
Exit Sub
End If
Next
Next
Next
'rotate 180 degrees and flip X
For Each fiInfo In fileArr
Dim bmp1 As Bitmap = New Bitmap(fiInfo.Name)
bmp1.RotateFlip(RotateFlipType.Rotate180FlipX)
For x As Integer = 0 To bmp1.Width - 1
For y As Integer = 0 To bmp1.Height - 1
If (bmp1.GetPixel(x, y) = bmp.GetPixel(x, y)) Then
MsgBox("Match. Nothing New.")
Exit Sub
End If
Next
Next
Next
MsgBox("New Pattern.")
My.Settings.FileInc += 1
Dim fileString As String = New String("")
If My.Settings.FileInc < 10 Then
fileString = "000" & My.Settings.FileInc.ToString
ElseIf My.Settings.FileInc > 9 And My.Settings.FileInc < 100 Then
fileString = "00" & My.Settings.FileInc.ToString
ElseIf My.Settings.FileInc > 99 And My.Settings.FileInc < 1000 Then
fileString = "0" & My.Settings.FileInc.ToString
Else
fileString = My.Settings.FileInc.ToString
End If
SaveFinalFile()
End Sub
'subs to save final file with others if appropriate.
Private Sub SaveFinalFile()
Dim frmLocX As Integer = Me.Location.X
Dim frmLocY As Integer = Me.Location.Y
Dim offsetX As Integer = Me.Size.Width - Me.DisplayRectangle.Width
Dim offsetY As Integer = Me.Size.Height - Me.DisplayRectangle.Height
x = x + frmLocX + offsetX
y = y + frmLocY + offsetY
Dim bmp As New Bitmap(wd, ht, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(x, y, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy)
totalFileString = "C:\Documents and Settings\Owner\My Documents\" & My.Settings.FileInc & ".bmp"
bmp.Save(totalFileString)
bmp.Dispose()
End Sub
Reply
Answers (
4
)
C# default connection string problem
C# new dbml file problem