Here you can find the source of rotateImage(BufferedImage imageToRotate, float degrees)
Parameter | Description |
---|---|
imageToRotate | a parameter |
degrees | 90 or -90 rotation. |
public static BufferedImage rotateImage(BufferedImage imageToRotate, float degrees)
//package com.java2s; /*//w ww . ja va 2 s. c om * ==================================================================== * * License: GNU General Public License * * Note: Original work copyright to respective authors * * This file is part of Blended (c) 2009-2010 University of Valladolid.. * * Blended is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * Blended is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Module developed at the University of Valladolid http://www.eduvalab.uva.es * * http://www.itnt.uva.es , http://www.eduvalab.uva.es * * Designed and directed by Juan Pablo de Castro with * the effort of many other students of telecommunication * engineering. * This module is provides as-is without any * guarantee. Use it as your own risk. * * @author Juan Pablo de Castro * @author Jesus Rodilana * @author Mar?a Jes?s Verd? * @author Luisa Regueras * @author Elena Verd? * * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package blended ***********************************************************************/ import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { /** * Rotates 90, -90 deegrees * @param imageToRotate * @param degrees 90 or -90 rotation. * @return */ public static BufferedImage rotateImage(BufferedImage imageToRotate, float degrees) { if (degrees != 90.0 && degrees != -90.0) throw new IllegalArgumentException("Only implemented +90 and -90 rotation"); BufferedImage rotatedImage = new BufferedImage(imageToRotate.getHeight(null), imageToRotate.getWidth(null), imageToRotate.getType()); Graphics2D g2d = (Graphics2D) rotatedImage.getGraphics(); g2d.rotate(Math.toRadians(degrees)); g2d.drawImage(imageToRotate, 0, -rotatedImage.getWidth(null), null); return rotatedImage; } }