I am trying to recreate the native component “Import Image” in my custom VB.net component to import image as colored mesh.
I managed to read the pixels from the original image:
Dim logo As New Drawing.Bitmap(ImagePath)
For i As Integer = 0 To logo.Width - 1
For j As Integer = 0 To logo.Height - 1
Dim PixelCol As Drawing.Color = logo.GetPixel(i, j)
However, I am not able to create the mesh (Delaunay.solver is very slow). Please, what is the most efficient way to turn the vertices and colors into a mesh in the same way as the component Import Image does it?
Thank you, David. It works!
Dim logo As New System.Drawing.Bitmap(path) Dim ImgX As Integer = logo.Width Dim ImgY As Integer = logo.Height Dim mymesh As Mesh = mesh.CreateFromPlane(myplane, New Interval(0, ImgX), New interval (0, ImgY), ImgX-1, ImgY-1) Dim newcolors As New list(Of System.Drawing.Color) For j As Integer = 0 To ImgY - 1 For i As Integer = 0 To ImgX - 1 newcolors.add(logo.GetPixel(i, ImgY - j - 1)) Next Next mymesh.VertexColors.SetColors(newcolors.toarray)