On Thu, 22 Dec 2022 22:02:39 GMT, Harshitha Onkar <[email protected]> wrote:

> > Why can't we scan all the pixels? It was the purpose of the test to ensure 
> > each window has the exact color. Does it take very long time?
> 
> There isn't a significant time difference but I think it might be a better 
> and efficient way. Since the right and bottom scans span across the entire 
> height and width of full screen window, it can test the extent of full screen 
> window effectively.

I agree that scanning one horizontal and one vertical line is much faster than 
scanning the entire rectangle. Yet scanning the entire rectangle guarantees 
there are no other colors in the entire capture of the image. The other 
approach, although faster, may not detect an occurrence of another color.

Using 
[`Stream.parallel`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/stream/BaseStream.html#parallel())
 may improve the speed of processing the entire rectangular image, for example 
by paralleling scanning the horizontal lines of the image.

Since it's not the reason for the test failure, I'd rather leave scanning the 
entire image.

> > Why is color tolerance needed? Is it to account for High DPI display? Can 
> > we use 
> > [`Robot.createMultiResolutionScreenCapture`](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/Robot.html#createMultiResolutionScreenCapture(java.awt.Rectangle))
> >  to ensure the `BufferedImage` contains the actual pixels rather a scaled 
> > down version?
> 
> There seems to be color issues at certain locations the color is not exactly 
> red or green hence the testColor check fails on some platforms. I'll have to 
> recheck and test the artifacts like Sergey mentioned it earlier.

If using `createMultiResolutionScreenCapture` resolves the problem, we should 
use it, High DPI displays are more common now and down-sampling the captured 
image could introduce artficats, even though it shouldn't because all the 
pixels are to be of the same color.

Did the entire window image have different colors or only the right-most and 
bottom-most lines?

-------------

PR: https://git.openjdk.org/jdk/pull/11462

Reply via email to