public static BufferedImage checkDeclare ( int width , int height , BufferedImage image , int type ) { if ( image == null ) return new BufferedImage ( width , height , type ) ; if ( image . getType ( ) != type ) return new BufferedImage ( width , height , type ) ; if ( image . getWidth ( ) != width || image . getHeight ( ) != height ) return new BufferedImage ( width , height , type ) ; return image ; }
If the provided image does not have the same shape and same type a new one is declared and returned .