public static boolean isAllOneColor ( BufferedImage image ) { int width = image . getWidth ( ) ; int height = image . getHeight ( ) ; int previousRgb = 0 ; boolean isFirst = true ; for ( int x = 0 ; x < width ; x ++ ) { for ( int y = 0 ; y < height ; y ++ ) { int rgb = image . getRGB ( x , y ) ; if ( isFirst ) { isFirst = false ; } else { if ( rgb != previousRgb ) { return false ; } } previousRgb = rgb ; } } return true ; }
Checks if an image is all of one color .