Here you can find the source of verticalFlip(BufferedImage img)
Parameter | Description |
---|---|
img | A source raster as a BufferedImage |
protected static BufferedImage verticalFlip(BufferedImage img)
//package com.java2s; import java.awt.*; import java.awt.image.*; public class Main { /**/*from www. j a v a2 s . c o m*/ * Flips image raster vertically * * @param img A source raster as a BufferedImage * * @return A vertically flipped image raster as a BufferedImage */ protected static BufferedImage verticalFlip(BufferedImage img) { if (null == img) return null; int w = img.getWidth(); int h = img.getHeight(); // BufferedImage flipImg = new BufferedImage(w, h, img.getColorModel().getTransparency() ); BufferedImage flipImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = flipImg.createGraphics(); java.awt.Composite prevComposite = g2d.getComposite(); g2d.setComposite(java.awt.AlphaComposite.Src); g2d.drawImage(img, 0, 0, w, h, 0, h, w, 0, null); g2d.setComposite(prevComposite); g2d.dispose(); return flipImg; } }