o codigo esta em um timer com interval de "1000" é um reconhecimento de img mas quando dentro de um timer ele consome muita memoria até dar erro!
preciso de uma ajuda para otimizar, preciso esvaziar a memoria quando o codigo chega ao fim ou coisa do tipo tentei varias coisa mais nada funcionou o desafio foi lançado! help me plx
Try
Dim bmpSource2 As Bitmap = New Bitmap("C:\Users\USER\Pictures\ox\others\efeito.bmp")
Dim bmpScreen2 As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Dim clrScreen, clrUL, clrUR, clrLL, clrLR As Color
'capture screen
Using g As Graphics = Graphics.FromImage(bmpScreen2)
g.CopyFromScreen(0, 0, 0, 0, bmpScreen2.Size)
End Using
For x = 1000 To 1100
For y = 300 To 350
clrScreen = bmpScreen2.GetPixel(x, y)
If clrScreen = clrUL Then
'found the upperleft pixel check upper right
clrScreen = bmpScreen2.GetPixel(x + bmpSource2.Width - 1, y)
If clrScreen = clrUR Then
clrScreen = bmpScreen2.GetPixel(x, y + bmpSource2.Height - 1)
If clrScreen = clrLL Then
clrScreen = bmpScreen2.GetPixel(x + bmpSource2.Width - 1, y + bmpSource2.Height - 1)
If clrScreen = clrLR Then
'Se achar
varial = varial + 1
End If
End If
End If
End If
Next
Next
Catch ex As ArgumentException
MsgBox("deu ruim")
Exit Sub
End Try
End Sub
Pergunta
Casalechi
o codigo esta em um timer com interval de "1000" é um reconhecimento de img mas quando dentro de um timer ele consome muita memoria até dar erro!
preciso de uma ajuda para otimizar, preciso esvaziar a memoria quando o codigo chega ao fim ou coisa do tipo tentei varias coisa mais nada funcionou o desafio foi lançado! help me plx
Try
Dim bmpSource2 As Bitmap = New Bitmap("C:\Users\USER\Pictures\ox\others\efeito.bmp")
Dim bmpScreen2 As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Dim clrScreen, clrUL, clrUR, clrLL, clrLR As Color
'capture screen
Using g As Graphics = Graphics.FromImage(bmpScreen2)
g.CopyFromScreen(0, 0, 0, 0, bmpScreen2.Size)
End Using
clrUL = bmpSource2.GetPixel(0, 0)
clrUR = bmpSource2.GetPixel(bmpSource2.Width - 1, 0)
clrLL = bmpSource2.GetPixel(0, bmpSource2.Height - 1)
clrLR = bmpSource2.GetPixel(bmpSource2.Width - 1, bmpSource2.Height - 1)
For x = 1000 To 1100
For y = 300 To 350
clrScreen = bmpScreen2.GetPixel(x, y)
If clrScreen = clrUL Then
'found the upperleft pixel check upper right
clrScreen = bmpScreen2.GetPixel(x + bmpSource2.Width - 1, y)
If clrScreen = clrUR Then
clrScreen = bmpScreen2.GetPixel(x, y + bmpSource2.Height - 1)
If clrScreen = clrLL Then
clrScreen = bmpScreen2.GetPixel(x + bmpSource2.Width - 1, y + bmpSource2.Height - 1)
If clrScreen = clrLR Then
'Se achar
varial = varial + 1
End If
End If
End If
End If
Next
Next
Catch ex As ArgumentException
MsgBox("deu ruim")
Exit Sub
End Try
End Sub
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.