Here is the code:
Dim img As B4XBitmap = LoadBitmap(File.DirAssets, "Immagine.png")
Log("Start...")
Dim start As Long = DateTime.Now
Dim bc As BitmapCreator
bc.Initialize(img.Width, img.Height)
bc.CopyPixelsFromBitmap(img)
Dim found As Boolean = False
For y = 0 To bc.mHeight - 1
For x = 0 To bc.mWidth - 1
Dim color As Int = bc.GetColor(x, y)
If color <> 0xFFFFFFFF Then ' it is not white
Dim elapsedTime As Long = DateTime.Now - start
Log("Found it as position X = " & x & " and Y = " & y)
Log("Time elaspsed = " & (elapsedTime / 1000) & " seconds")
found = True
Exit
End If
Next
If found Then Exit
Next
The code works correctly for me to locate any pixe quickly. But in the end I decided to do something else.
I attach an example of the program to comment and see what error may be happening. The program does:
- 1st create image by going through the color palette every pixel ImageView1 and memorizes the color number and position coordinates on a MAP
- 2nd executes a correction process to re-position the original image to procesed ImageView1 tranformed in its correct place on ImageView2
- 3rd reads all the pixels, looking for the corresponding color within the map (as if it were an index) and creates a map with the relationship between the x and origin coordinates, and the x and destination coordinates of the transformed image.
It seems to work, but there is something that doesn't quite work, it seems to me that when I do the loop to show all the colors, it doesn't do it correctly and repeats colors (which then uses the same index and then creates the error)