Example usage for java.awt.image BufferedImage getHeight

List of usage examples for java.awt.image BufferedImage getHeight

Introduction

In this page you can find the example usage for java.awt.image BufferedImage getHeight.

Prototype

public int getHeight() 

Source Link

Document

Returns the height of the BufferedImage .

Usage

From source file:Utils.java

/**
 * Produces a copy of the supplied image
 *
 * @param image The original image//from ww  w. j av a 2 s .  c o  m
 * @return The new BufferedImage
 */
public static BufferedImage copyImage(BufferedImage image) {
    return scaledImage(image, image.getWidth(), image.getHeight());
}

From source file:BufferedImages.java

/**
 * Returns a {@link BufferedImage} with the specified image type, where the
 * graphical content is a copy of the specified image.
 * /*  w ww  . ja v a2s.c o  m*/
 * @param img      The image to copy.
 * @param imageType   The image type for the image to return.
 * @return         A copy of the specified image.
 */
public static BufferedImage copy(BufferedImage img, int imageType) {
    int width = img.getWidth();
    int height = img.getHeight();

    BufferedImage newImage = new BufferedImage(width, height, imageType);
    Graphics g = newImage.createGraphics();

    g.drawImage(img, 0, 0, null);

    g.dispose();

    return newImage;
}

From source file:Main.java

public static BufferedImage resize(int targetWidth, int targetHeight, BufferedImage src) {
    double scaleW = (double) targetWidth / (double) src.getWidth();
    double scaleH = (double) targetHeight / (double) src.getHeight();

    double scale = scaleW < scaleH ? scaleW : scaleH;

    BufferedImage result = new BufferedImage((int) (src.getWidth() * scale), (int) (src.getHeight() * scale),
            BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2d = result.createGraphics();
    g2d.drawImage(src, 0, 0, result.getWidth(), result.getHeight(), null);
    g2d.dispose();//from   w ww. j  a v a 2  s. c  o  m

    return result;
}

From source file:business.Reciept.java

private static model.Image createImage(MultipartFile multiPartFile) throws Exception {

    byte[] byteArray = multiPartFile.getBytes();
    BufferedImage image = ImageIO.read(multiPartFile.getInputStream());
    int height = image.getHeight();
    int width = image.getWidth();

    return new model.Image(byteArray, multiPartFile.getContentType(), height, width);

}

From source file:Main.java

protected static boolean testNeighbour(BufferedImage source, int x, int y, boolean alpha) {
    if (x >= 0 && y >= 0 && x < source.getWidth() && y < source.getHeight()) {
        int gray = source.getRGB(x, y) & 0x000000ff;
        int alphaI = (source.getRGB(x, y) & 0xff000000) >>> 24;
        return (alpha && alphaI == 0) || (!alpha && gray == 255);
    }/*from w  ww.j a  v a  2  s.  com*/
    return true;
}

From source file:Main.java

public static BufferedImage joinBufferedImage(BufferedImage img1, BufferedImage img2) {
    int offset = 2;
    int width = img1.getWidth() + img2.getWidth() + offset;
    int height = Math.max(img1.getHeight(), img2.getHeight()) + offset;
    BufferedImage newImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = newImage.createGraphics();
    Color oldColor = g2.getColor();
    g2.setPaint(Color.BLACK);//  w  w w  . j a  v a  2 s .  co  m
    g2.fillRect(0, 0, width, height);
    g2.setColor(oldColor);
    g2.drawImage(img1, null, 0, 0);
    g2.drawImage(img2, null, img1.getWidth() + offset, 0);
    g2.dispose();
    return newImage;
}

From source file:com.cisco.surf.jenkins.plugins.jenkow.tests.DiagramGeneration.DiagramTest.java

private static String getGeo(BufferedImage img) {
    return img.getWidth() + "x" + img.getHeight();
}

From source file:com.buddycloud.mediaserver.business.util.ImageUtils.java

public static boolean isSquare(BufferedImage img) {
    return img.getHeight() == img.getWidth();
}

From source file:Main.java

private static BufferedImage prepareImage(BufferedImage image, int shadowSize) {
    BufferedImage subject = new BufferedImage(image.getWidth() + shadowSize * 2,
            image.getHeight() + shadowSize * 2, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2 = subject.createGraphics();
    g2.drawImage(image, null, shadowSize, shadowSize);
    g2.dispose();/*from  w w  w .j  a v  a2  s .c  o m*/

    return subject;
}

From source file:Main.java

/**
 * Creates a shadow mask//w  w w .j av  a2  s.c  o  m
 * @param image
 * @param shadowColor
 * @param shadowOpacity
 * @return
 */
private static BufferedImage createShadowMask(BufferedImage image, Color shadowColor, float shadowOpacity) {
    BufferedImage mask = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2d = mask.createGraphics();
    g2d.drawImage(image, 0, 0, null);
    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN, shadowOpacity));
    g2d.setColor(shadowColor);
    g2d.fillRect(0, 0, image.getWidth(), image.getHeight());
    g2d.dispose();

    return mask;
}