Example usage for java.awt.image BufferedImage TYPE_INT_RGB

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

Introduction

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

Prototype

int TYPE_INT_RGB

To view the source code for java.awt.image BufferedImage TYPE_INT_RGB.

Click Source Link

Document

Represents an image with 8-bit RGB color components packed into integer pixels.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    BufferedImage bufferedImage = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);

    int rgb = bufferedImage.getRGB(1, 1);

    int w = bufferedImage.getWidth(null);
    int h = bufferedImage.getHeight(null);
    int[] rgbs = new int[w * h];
    bufferedImage.getRGB(0, 0, w, h, rgbs, 0, w);

    rgb = 0xFF00FF00; // green
    bufferedImage.setRGB(1, 1, rgb);/*from   w w w  .j  a va  2s .  c o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    int width = 100;
    int height = 100;

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

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    int width = 100;
    int height = 100;

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

    bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    int width = 100;
    int height = 100;

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

    bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

}

From source file:Main.java

public static void main(String[] args) {
    Image image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB);

    JFrame f = new JFrame();
    f.setIconImage(image);/*from w  w w.j a  v  a 2  s. co m*/
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setSize(600, 400);
    f.setVisible(true);

    JFileChooser chooser = new JFileChooser();
    chooser.showOpenDialog(f);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    BufferedImage bsrc = ImageIO.read(new File("a.jpg"));
    BufferedImage bdest = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bdest.createGraphics();
    AffineTransform at = AffineTransform.getScaleInstance(2, 2);
    g.drawRenderedImage(bsrc, at);//from ww  w .ja v a 2 s . c  o  m
    ImageIO.write(bdest, "JPG", new File("b.jpg"));
}

From source file:Main.java

public static void main(String arg[]) throws Exception {

    String yourText = "java2s.com";
    BufferedImage bufferedImage = new BufferedImage(170, 30, BufferedImage.TYPE_INT_RGB);

    Graphics graphics = bufferedImage.getGraphics();
    graphics.setColor(Color.LIGHT_GRAY);
    graphics.fillRect(0, 0, 200, 50);/*from  ww  w  .  j  a va  2  s .  co  m*/
    graphics.setColor(Color.BLACK);
    graphics.setFont(new Font("Arial Black", Font.BOLD, 20));
    graphics.drawString(yourText, 10, 25);

    ImageIO.write(bufferedImage, "jpg", new File("C:/Users/image.jpg"));

    System.out.println("Image Created");
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    int width = 100;// width of your image
    int height = 100; // height of your image

    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            int grayscale = 123;
            int colorValue = grayscale | grayscale << 8 | grayscale << 16;
            img.setRGB(x, y, colorValue);
        }/*  w  w w . j  av a2  s.  c  o  m*/
    }
    ImageIO.write(img, "png", new File("c:/Java_Dev/output.png"));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Image image = new ImageIcon("image.gif").getImage();

    BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null),
            BufferedImage.TYPE_INT_RGB);

    Graphics2D g = bimage.createGraphics();
    g.drawImage(image, 0, 0, null);//from ww w.ja  v  a 2s . c om
    g.dispose();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    ImageIcon ii = new ImageIcon("C:/Java_Dev/test.jpg");
    BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = (Graphics2D) bi.createGraphics();
    g2d.addRenderingHints(//w w w .  jav  a 2s. c om
            new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
    boolean b = g2d.drawImage(ii.getImage(), 0, 0, 50, 50, null);
    System.out.println(b);
    ImageIO.write(bi, "jpg", new File("C:/Java_Dev/test.jpg"));
}