List of utility methods to do BufferedImage Flip
BufferedImage | flipImage(final BufferedImage image, final boolean horizontal, final boolean vertical) Flips an image horizontally and/or vertically. int x = 0; int y = 0; int w = image.getWidth(); int h = image.getHeight(); final BufferedImage out = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); final Graphics2D g2d = out.createGraphics(); if (horizontal) { x = w; ... |
BufferedImage | flipImage(Object original, boolean flipX, boolean flipY) flip Image BufferedImage originalImage = (BufferedImage) original; if (!flipX && !flipY) return originalImage; int x = 0; int y = 0; int width = originalImage.getWidth(); int height = originalImage.getHeight(); BufferedImage flippedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); ... |
BufferedImage | flipImageHorizontally(BufferedImage image) A method which will invert an image with respect to its y-axis BufferedImage flipped = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
AffineTransform tran = AffineTransform.getTranslateInstance(image.getWidth(), 0);
AffineTransform flip = AffineTransform.getScaleInstance(-1d, 1d);
tran.concatenate(flip);
Graphics2D g = flipped.createGraphics();
g.setTransform(tran);
g.drawImage(image, 0, 0, null);
g.dispose();
...
|
void | flipImageVertically(BufferedImage theImage) Flips the supplied BufferedImage vertically. WritableRaster raster = theImage.getRaster(); Object scanline1 = null; Object scanline2 = null; for (int i = 0; i < theImage.getHeight() / 2; i++) { scanline1 = raster.getDataElements(0, i, theImage.getWidth(), 1, scanline1); scanline2 = raster.getDataElements(0, theImage.getHeight() - i - 1, theImage.getWidth(), 1, scanline2); raster.setDataElements(0, i, theImage.getWidth(), 1, scanline2); raster.setDataElements(0, theImage.getHeight() - i - 1, theImage.getWidth(), 1, scanline1); ... |
BufferedImage | flipVertical(BufferedImage im) flip Vertical int height = im.getHeight(); int width = im.getWidth(); DataBuffer db = im.getRaster().getDataBuffer(); if (db instanceof DataBufferInt) { int imdata[] = ((DataBufferInt) db).getData(); BufferedImage im2 = new BufferedImage(width, height, im.getType()); int imdata2[] = ((DataBufferInt) (im2.getRaster().getDataBuffer())).getData(); int stride = width; ... |
BufferedImage | flipVertically(BufferedImage image) Create a vertically flipped version of the given image. int w = image.getWidth(); int h = image.getHeight(); BufferedImage newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g = newImage.createGraphics(); g.drawImage(image, 0, h, w, -h, null); g.dispose(); return newImage; |
BufferedImage | flipVertically(BufferedImage image) flip Vertically return transform(image, 1, -1, 0, -image.getHeight());
|
BufferedImage | flipVertically(BufferedImage image, RenderingHints hints) Flips the image vertically if (image == null) { return null; AffineTransform at = getXFlipTransform(image.getHeight(null)); AffineTransformOp op = new AffineTransformOp(at, hints); return op.filter(image, null); |
BufferedImage | flipVertically(BufferedImage source) Flips a given image vertically. w = source.getWidth(); h = source.getHeight(); bimg = new BufferedImage(w, h, source.getType()); g2 = bimg.createGraphics(); g2.drawImage(source, 0, 0, w, h, 0, h, w, 0, null); g2.dispose(); return bimg; |
BufferedImage | horizontalflip(BufferedImage img) horizontalflip 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(); return dimg; |