Java BufferedImage Flip flipHorizontal(BufferedImage bufferedImage)

Here you can find the source of flipHorizontal(BufferedImage bufferedImage)

Description

Gira una imagen en sentido horizontal

License

Open Source License

Parameter

Parameter Description
bufferedImage la imagen que se desea girar

Return

BufferedImage es la imagen girada

Declaration

public static BufferedImage flipHorizontal(BufferedImage bufferedImage) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

import java.awt.image.*;

import javax.swing.*;

public class Main {
    /**/* w  ww. j a  v a  2  s.c  o  m*/
     * Gira una imagen en sentido horizontal
     *
     * @param bufferedImage la imagen que se desea girar
     *
     * @return BufferedImage es la imagen girada
     */
    public static BufferedImage flipHorizontal(BufferedImage bufferedImage) {
        int w = bufferedImage.getWidth();
        int h = bufferedImage.getHeight();
        BufferedImage bi = new BufferedImage(w, h, bufferedImage.getType());
        Graphics2D g = bi.createGraphics();
        g.drawImage(bufferedImage, 0, 0, w, h, w, 0, 0, h, null);
        g.dispose();
        return bi;
    }

    /**
     * Obtiene el ancho de una Image
     */
    public static int getWidth(Image imagen) {
        int width = new ImageIcon(imagen).getIconWidth();
        return width;
    }

    /**
     * Obtiene el ancho de un IconImage
     */
    public static int getWidth(ImageIcon imagen) {
        return imagen.getIconWidth();
    }

    /**
     * Obtiene el alto de una Image
     */
    public static int getHeight(Image imagen) {
        int height = new ImageIcon(imagen).getIconHeight();
        return height;
    }

    /**
     * Obtiene el alto de un IconImage
     */
    public static int getHeight(ImageIcon imagen) {
        return imagen.getIconHeight();
    }
}

Related

  1. flip(BufferedImage myImage, int type)
  2. flipAroundX(BufferedImage image)
  3. flipBothVerticallyAndHorizontallyWithAffineTransformOp(BufferedImage srcImage)
  4. flipBufferedImage(BufferedImage bufferedImage)
  5. flipBufferedImageVertically(BufferedImage bufferedImage)
  6. flipHorizontally(BufferedImage srcImage)
  7. flipImage(BufferedImage image)
  8. flipImage(final BufferedImage image, final boolean horizontal, final boolean vertical)
  9. flipImage(Object original, boolean flipX, boolean flipY)