Reputation: 13
Basically, what I want to do is this:
Dim colors1(100, 100) As New List(Of Color)
I need to create a matrix with the New List(Of Color)
.
I will explain better...
I want to read all the colors of the pixels of my image, and usualy i would do that by reading line by line.
But that is not the case.
I divide the image in 8x8 squares and i want create an matrix(whit position of square)and the List(Of Color)(whit the colors of that square) that says all the colors of each square. Infortunaly when i try do this Dim colors1(100,100) as List(Of Color)
the program break.
Upvotes: 1
Views: 368
Reputation: 34429
Try this
Dim colors1 As New List(Of List(Of Color))
For i As Integer = 0 To 99
Dim newColors As New List(Of Color)
colors1.Add(newColors)
For j As Integer = 0 To 99
newColors.Add(New Color)
Next
Next
Upvotes: 1
Reputation: 898
Well, are you wanting to use an Array
or a List
for this?
If you want a fixed 100x100 matrix then you should use a 2D Array
since arrays are fixed size.
If you're happy to use a fixed 100x100 2D Array
, you can declare it like:
Dim colors1(100, 100) As Color
Set it like this:
colors1(5, 2) = Color.Aqua
And then use it like this:
' Sets the textbox background color to Aqua
TextBox1.BackColor = colors1(5, 2)
Does that achieve what you're trying to do? Or did you need the List for another reason?
Upvotes: 0