Java BufferedImage Flip horizontalflip(BufferedImage img)

Here you can find the source of horizontalflip(BufferedImage img)

Description

horizontalflip

License

Apache License

Declaration

public static BufferedImage horizontalflip(BufferedImage img) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage horizontalflip(BufferedImage img) {
        int w = img.getWidth();
        int h = img.getHeight();
        BufferedImage dimg = new BufferedImage(w, h, img.getType());
        Graphics2D g = dimg.createGraphics();
        g.drawImage(img, 0, 0, w, h, w, 0, 0, h, null);
        g.dispose();/*from  www. ja va2  s .c o  m*/
        return dimg;
    }

    public static void drawImage(BufferedImage srcImg, BufferedImage img2Draw, int w, int h) {
        if (w == -1)
            w = (int) (srcImg.getWidth() / 2);
        if (h == -1)
            h = (int) (srcImg.getHeight() / 2);
        System.out.println("AWT Image Wt: " + w + " And Ht: " + h);
        Graphics2D g2 = srcImg.createGraphics();
        g2.drawImage(img2Draw, w, h, null);
        g2.dispose();
    }
}

Related

  1. flipVertical(BufferedImage im)
  2. flipVertically(BufferedImage image)
  3. flipVertically(BufferedImage image)
  4. flipVertically(BufferedImage image, RenderingHints hints)
  5. flipVertically(BufferedImage source)
  6. verticalFlip(BufferedImage img)
  7. verticalFlip(BufferedImage img)