Here you can find the source of rotate(BufferedImage src)
public static BufferedImage rotate(BufferedImage src)
//package com.java2s; /*//www. j av a 2 s . co m * Copyright (C) 2011 0xlab - http://0xlab.org/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Authored by Wei-Ning Huang <azhuang@0xlab.org> */ import java.awt.image.BufferedImage; public class Main { public static BufferedImage rotate(BufferedImage src) { int width = src.getWidth(); int height = src.getHeight(); BufferedImage rotated = new BufferedImage(height, width, src.getColorModel().getTransparency()); for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { rotated.setRGB(j, width - i - 1, src.getRGB(i, j)); } } return rotated; } }