Java Utililty Methods BufferedImage Flip

List of utility methods to do BufferedImage Flip

Description

The list of methods to do BufferedImage Flip are organized into topic(s).

Method

BufferedImageflipImage(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;
...
BufferedImageflipImage(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);
...
BufferedImageflipImageHorizontally(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();
...
voidflipImageVertically(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);
...
BufferedImageflipVertical(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;
...
BufferedImageflipVertically(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;
BufferedImageflipVertically(BufferedImage image)
flip Vertically
return transform(image, 1, -1, 0, -image.getHeight());
BufferedImageflipVertically(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);
BufferedImageflipVertically(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;
BufferedImagehorizontalflip(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;