private static void rotate( BufferedImage srcImg, BufferedImage leftImg, BufferedImage rightImg, List<BufferedImage> outImages, int maxAmount) { for (int i = ANGLE_DEVIATION_STEP; i < MAX_ANGLE_DEVIATION; i = i + ANGLE_DEVIATION_STEP) { // outImages.add( // compose( // rotate(leftImg, i*Math.PI/180), // rightImg, // ImageUtils.deepCopy(srcImg))); // outImages.add( // compose( // rotate(leftImg, -i*Math.PI/180), // rightImg, // ImageUtils.deepCopy(srcImg))); // // // outImages.add( // compose( // leftImg, // rotate(rightImg, i*Math.PI/180), // ImageUtils.deepCopy(srcImg))); // outImages.add( // compose( // leftImg, // rotate(rightImg, -i*Math.PI/180), // ImageUtils.deepCopy(srcImg))); if (maxAmount > outImages.size()) outImages.add( compose( rotate(leftImg, i * Math.PI / 180), rotate(rightImg, i * Math.PI / 180), ImageUtils.deepCopy(srcImg))); if (maxAmount > outImages.size()) outImages.add( compose( rotate(leftImg, -i * Math.PI / 180), rotate(rightImg, -i * Math.PI / 180), ImageUtils.deepCopy(srcImg))); // outImages.add( // compose( // rotate(leftImg, -i*Math.PI/180), // rotate(rightImg, i*Math.PI/180), // ImageUtils.deepCopy(srcImg))); // outImages.add( // compose( // rotate(leftImg, i*Math.PI/180), // rotate(rightImg, -i*Math.PI/180), // ImageUtils.deepCopy(srcImg))); } // for (int i = 0; i < MAX_ANGLE_DEVIATION; i++) return; }
private static BufferedImage rotate(BufferedImage inImg, double angle) { BufferedImage outImg = ImageUtils.deepCopy(inImg); Graphics2D gr = (Graphics2D) outImg.getGraphics(); // rotate in center gr.rotate(angle, inImg.getWidth() / 2, inImg.getWidth() / 2); gr.drawImage(inImg, 0, 0, inImg.getWidth(), inImg.getWidth(), null); gr.dispose(); return outImg; }