How to rotate around the image center by itext?

前端 未结 2 784
不知归路
不知归路 2021-01-24 15:48
double degPi = degrees * Math.PI / 180;   
double a = Math.cos(degPi)*tImgCover.getScaledHeight();
double b = Math.sin(degPi)*tImgCover.getScaledWidth();
double c = -Mat         


        
2条回答
  •  一生所求
    2021-01-24 15:56

        public static BufferedImage rotateClockwise90( BufferedImage inputImage ){
            int width = inputImage.getWidth();
            int height = inputImage.getHeight();
            BufferedImage returnImage = new BufferedImage( height, width , inputImage.getType()  );
    
            for( int x = 0; x < width; x++ ) {
                for( int y = 0; y < height; y++ ) {
                    returnImage.setRGB( height-y-1, x, inputImage.getRGB( x, y  )  );
    
                }
            }
            return returnImage;
    }
    

提交回复
热议问题