Java BufferedImage Rotate rotate(BufferedImage src)

Here you can find the source of rotate(BufferedImage src)

Description

rotate

License

Apache License

Declaration

public static BufferedImage rotate(BufferedImage src) 

Method Source Code


//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;
    }
}

Related

  1. rotate(BufferedImage img, int angle)
  2. rotate(BufferedImage img, int angle)
  3. rotate(BufferedImage img, int angle)
  4. rotate(BufferedImage img, int b, int a, int angle)
  5. rotate(BufferedImage source, int angle)
  6. rotate(final BufferedImage image, final int angle)
  7. rotate(Graphics2D g, BufferedImage newImg, int x, int y, int width, int height, int angle, int originX, int originY)
  8. rotate90(BufferedImage bi)
  9. rotate90(BufferedImage img, boolean left)