Public Function GetIdColor(Byval pColor as Color) as Integer If lCollection.Contains(pColor) Then Return lCollection.IndexOf(pColor) Else lCollection.Add(pColor) Return GetIdColor(pColor) End if End Function
Public Class Form1 Dim image1 As Bitmap Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click Try ' Retrieve the image. image1 = New Bitmap("C:\VB\test.bmp",True) Dim x, y As Integer ' Loop through the images pixels. For x = 0 To image1.Width - 1 For y = 0 To image1.Height - 1 ' que dois-je mette à cet endroit???? Next Next end try end sub
Option Explicit On Option Strict On Public Class Form1 Dim image1 As Bitmap Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Retrieve the image. image1 = New Bitmap("C:\test.bmp", True) Dim x, y As Integer ' Loop through the images pixels For x = 0 To image1.Width - 1 For y = 0 To image1.Height - 1 Next Next ' Set the PictureBox to display the image. Juste pour voir! PictureBox1.Image = image1 End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Function GetIdColor(ByVal pColor As Color) As Integer Private/color lCollection As New List(Of Color) If lCollection.Contains(pColor) Then Return lCollection.IndexOf(pColor) Else lCollection.Add(pColor) Return GetIdColor(pColor) End If End Function
Option Explicit On Option Strict On Public Class Form1 Dim image1 As Bitmap Dim tableau(200, 300) As Integer Private lCollection As New List(Of Color) Public Function GetIdColor(ByVal pColor As Color) As Integer If lCollection.Contains(pColor) Then Return lCollection.IndexOf(pColor) Else lCollection.Add(pColor) Return GetIdColor(pColor) End If End Function Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Retrieve the image. image1 = New Bitmap("C:\test.bmp", True) Dim x, y As Integer ' Loop through the images pixels For x = 0 To image1.Width - 1 For y = 0 To image1.Height - 1 tableau(x, y) = GetIdColor(image1.GetPixel(x, y)) Console.Out.WriteLine(tableau(x, y)) Next Next ' Set the PictureBox to display the image. Juste pour voir! PictureBox1.Image = image1 End Sub End Class