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

BufferedImageflip(BufferedImage image, boolean flipHorizontal, boolean flipVertical)
the graphic2d changes, must use the new one for future operations.
Point scale = new Point(1, 1);
Point translate = new Point(0, 0);
if (flipHorizontal) {
    scale.x = -1;
    translate.x = -image.getWidth();
if (flipVertical) {
    scale.y = -1;
...
BufferedImageflip(BufferedImage image, int direction)
Flip the image and return a new image
BufferedImage workImage = new BufferedImage(image.getWidth(), image.getHeight(), image.getTransparency());
boolean flipHorizontal = (direction & 1) == 1;
boolean flipVertical = (direction & 2) == 2;
int workW = image.getWidth() * (flipHorizontal ? -1 : 1);
int workH = image.getHeight() * (flipVertical ? -1 : 1);
int workX = flipHorizontal ? image.getWidth() : 0;
int workY = flipVertical ? image.getHeight() : 0;
Graphics2D wig = workImage.createGraphics();
...
BufferedImageflip(BufferedImage myImage, int type)
flip
AffineTransform tx;
AffineTransformOp op;
switch (type) {
case HORIZONTAL:
    tx = AffineTransform.getScaleInstance(-1, 1);
    tx.translate(-myImage.getWidth(), 0);
    op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    myImage = op.filter(myImage, null);
...
BufferedImageflipAroundX(BufferedImage image)
Flips the image horizontally
AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
tx.translate(0, -image.getHeight(null));
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
image = op.filter(image, null);
return image;
BufferedImageflipBothVerticallyAndHorizontallyWithAffineTransformOp(BufferedImage srcImage)
flip Both Vertically And Horizontally With Affine Transform Op
AffineTransform tx = AffineTransform.getScaleInstance(-1, -1);
tx.translate(-srcImage.getWidth(null), -srcImage.getHeight(null));
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
return op.filter(srcImage, null);
BufferedImageflipBufferedImage(BufferedImage bufferedImage)
flip Buffered Image
return flipBufferedImageX(flipBufferedImageY(bufferedImage));
BufferedImageflipBufferedImageVertically(BufferedImage bufferedImage)
flip Buffered Image Vertically
BufferedImage bufferedImageFixed = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(),
        bufferedImage.getType());
AffineTransform at = AffineTransform.getScaleInstance(1, -1);
at.translate(0, -bufferedImage.getHeight(null));
AffineTransformOp ato = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
ato.filter(bufferedImage, bufferedImageFixed);
return bufferedImageFixed;
BufferedImageflipHorizontal(BufferedImage bufferedImage)
Gira una imagen en sentido horizontal
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;
voidflipHorizontally(BufferedImage srcImage)
flip Horizontally
int srcWidth = srcImage.getWidth();
int srcHeight = srcImage.getHeight();
WritableRaster srcRaster = srcImage.getRaster();
DataBuffer srcDataBuffer = srcRaster.getDataBuffer();
int srcDataBufferOffset = srcDataBuffer.getOffset();
int srcNumBands = srcRaster.getNumBands();
if (srcNumBands == 1) {
    if (srcDataBuffer instanceof DataBufferUShort) {
...
BufferedImageflipImage(BufferedImage image)
flip Image
AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);
tx.translate(-(image.getWidth(null)), 0);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
return op.filter(image, null);