Java BufferedImage Operation criarImagemCompativel(BufferedImage original, int largura, int altura, boolean manterQualidade)

Here you can find the source of criarImagemCompativel(BufferedImage original, int largura, int altura, boolean manterQualidade)

Description

criar Imagem Compativel

License

LGPL

Declaration

public static BufferedImage criarImagemCompativel(BufferedImage original, int largura, int altura,
            boolean manterQualidade) 

Method Source Code


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

import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage criarImagemCompativel(BufferedImage original, int largura, int altura,
            boolean manterQualidade) {
        GraphicsConfiguration graphicsConfiguration = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();

        BufferedImage imagemCompativel = graphicsConfiguration.createCompatibleImage(largura, altura,
                original.getTransparency());
        Graphics2D g = (Graphics2D) imagemCompativel.getGraphics();

        if (manterQualidade) {
            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        }/*from  w ww .j  a va2s .co  m*/

        g.drawImage(original, 0, 0, largura, altura, null);
        g.dispose();

        return imagemCompativel;
    }

    public static BufferedImage criarImagemCompativel(BufferedImage original, boolean manterQualidade) {
        return criarImagemCompativel(original, original.getWidth(null), original.getHeight(), manterQualidade);
    }
}

Related

  1. composite(BufferedImage bg, BufferedImage fg)
  2. computeBrightnesses(final BufferedImage image)
  3. computeTrimmedBounds(BufferedImage image, Rectangle tbounds)
  4. conformImageToInt(BufferedImage in)
  5. contrast(BufferedImage src, float scaleFactor)
  6. cutToSquare(BufferedImage src)
  7. cylindricalMapping(BufferedImage img, double f)
  8. darkenImage(final BufferedImage image, final float darken)
  9. declareNewBufferedImage(int x, int y)