Java BufferedImage Operation conformImageToInt(BufferedImage in)

Here you can find the source of conformImageToInt(BufferedImage in)

Description

conform Image To Int

License

LGPL

Declaration

public static BufferedImage conformImageToInt(BufferedImage in) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.awt.*;
import java.awt.image.*;

public class Main {
    public static boolean warn = true;

    public static BufferedImage conformImageToInt(BufferedImage in) {
        return convertImage(in, BufferedImage.TYPE_INT_RGB);
    }/*from  w  w  w  . jav  a  2  s  . co  m*/

    /**
     * Ensure an image is of the right format, converting it to the
     * format if necessary.
     * @param in The input image, in any format.
     * @param type The desired type, e.g. BufferedImage.TYPE_3BYTE_BGR
     * @return An image with analagous content as in, but of the
     * requested type. Or, if the input image was already in the
     * requested format, the input image is returned.
     **/
    public static BufferedImage convertImage(BufferedImage in, int type) {
        if (in.getType() == type)
            return in;

        if (warn) {
            System.out.println("ImageUtil: Performing slow image type conversion");
            warn = false;
        }

        int w = in.getWidth();
        int h = in.getHeight();

        BufferedImage out = new BufferedImage(w, h, type);
        Graphics g = out.getGraphics();

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

        g.dispose();

        return out;
    }
}

Related

  1. cleanBinaryImage(BufferedImage image)
  2. compose(BufferedImage image, BufferedImage mask)
  3. composite(BufferedImage bg, BufferedImage fg)
  4. computeBrightnesses(final BufferedImage image)
  5. computeTrimmedBounds(BufferedImage image, Rectangle tbounds)
  6. contrast(BufferedImage src, float scaleFactor)
  7. criarImagemCompativel(BufferedImage original, int largura, int altura, boolean manterQualidade)
  8. cutToSquare(BufferedImage src)
  9. cylindricalMapping(BufferedImage img, double f)