Java BufferedImage Operation cascadeHorizontal(final BufferedImage... images)

Here you can find the source of cascadeHorizontal(final BufferedImage... images)

Description

cascade Horizontal

License

Open Source License

Declaration

public static BufferedImage cascadeHorizontal(final BufferedImage... images) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage cascadeHorizontal(final BufferedImage... images) throws Exception {
        if (images.length == 0) {
            return null;
        }//w w w.j  ava 2s  .  c om
        if (images.length == 1) {
            return images[0];
        }

        int height = images[0].getHeight();
        int width = 0;
        for (BufferedImage image : images) {
            if (image == null) {
                continue;
            }

            if (image.getHeight() != height) {
                throw new Exception("Images must be equal height.");
            }
            width += image.getWidth();
        }

        BufferedImage cascade = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

        Graphics2D graphics = cascade.createGraphics();
        int index = 0;
        for (BufferedImage image : images) {
            if (image == null) {
                continue;
            }
            graphics.drawImage(image, index, 0, null);
            index += image.getWidth();
        }
        graphics.dispose();

        return cascade;

    }
}

Related

  1. boostBufferedImagePerformance(BufferedImage image, boolean translucent)
  2. buildColorStatisticsOfImage(BufferedImage image)
  3. buildingCoordinatesInImage(BufferedImage imageSection)
  4. buildPixelAverages(BufferedImage a, Rectangle[] sectors)
  5. buildSectors(BufferedImage a, int sqrtSectors)
  6. changeContrast(BufferedImage img, float amount)
  7. changeImageToArray(BufferedImage bufferedImage)
  8. checkIfManyColors(BufferedImage image)
  9. checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2)