Java BufferedImage Create getBufferedImageAsType(int type, BufferedImage image, int sizeX, int sizeY)

Here you can find the source of getBufferedImageAsType(int type, BufferedImage image, int sizeX, int sizeY)

Description

get Buffered Image As Type

License

Open Source License

Declaration

private static BufferedImage getBufferedImageAsType(int type, BufferedImage image, int sizeX, int sizeY) 

Method Source Code

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

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

public class Main {
    private static BufferedImage getBufferedImageAsType(int type, BufferedImage image, int sizeX, int sizeY) {
        if (image.getType() == type) {
            return image;
        } else {/*from w  ww.  j av a  2  s .  c o m*/
            // 'type' should be one of BufferedImage.TYPE_*
            BufferedImage result = new BufferedImage(sizeX, sizeY, type);
            Graphics g = result.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();

            return result;
        }
    }
}

Related

  1. getBufferedImage(byte[] imgStr)
  2. getBufferedImage(Component comp, BufferedImage image)
  3. getBufferedImage(File file)
  4. getBufferedImage(String imageFile, Component c)
  5. getBufferedImage(String imagePath)
  6. getBufferedImageBytes(BufferedImage bufferedImage)
  7. getBufferedImaged(Image img, int width, int height)
  8. getBufferedImageFrom3bytePixelArray(int[] rgb, int width, int height)
  9. getBufferedImageFromFile(String fileName)