I need to search in an image for the number and position of pixels of a certain color.
As the screen changes quickly and I need to make sure that I get a consistent state, I thought of first capturing the image and then analyze it for the pixels of the certain color.
The color matching part - with some pre-captured test image - was easy:
set width to imageSize(testImage).x // loop over whole width of the (first line) of testImage, to find points of the relevant TestColor. repeat width-1 times set point to (repeatIndex(),1) set currentPointColor to imageColorAtLocation(testImage,point) if currentPointColor equals TestColor then insert point.x into PointList end if end repeat
This works great, if testImage is an image I have already in the suite.
But how do I get an up-to-date image to analyze? If I capture it with CapureScreen, I’m not able to work with it afterwards, as something like
set testImage to file (ImagePath & "xyz.tiff") // load image xyz...
fails with STFileException File /xzy.tiff couldn’t be read using the defaultStringEncoding (UTF8)
How can I access such a dynamically created image?
Or should I use some standard search functionality of Eggplant instead? It is important that I can provide the pixel color as value, not as an pre-captured image…