List of usage examples for javax.imageio ImageIO read
public static BufferedImage read(ImageInputStream stream) throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedImage image = ImageIO.read(Main.class.getResource("S.jpg")); }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedImage image = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); System.out.println(image == null); int width = image.getWidth(); int height = image.getHeight(); System.out.println(width + "x" + height); for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { System.out.printf("%04X ", image.getRGB(col, row)); }// w ww . j av a 2 s . c o m System.out.println(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedImage img = ImageIO.read(new File("c:/Java_Dev/a.jpg")); int height = img.getHeight(); int width = img.getWidth(); System.out.println(height + " " + width + " " + img.getRGB(30, 30)); for (int h = 1; h < height; h++) { for (int w = 1; w < width; w++) { int rgb = img.getRGB(w, h); int red = (rgb >> 16) & 0x000000FF; int green = (rgb >> 8) & 0x000000FF; int blue = (rgb) & 0x000000FF; if (red == 0 && green == 0 && blue == 0) { System.out.println("Black"); }//from ww w . j ava2 s. c o m } } }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedImage img = colorImage(ImageIO.read(new File("NWvnS.png"))); ImageIO.write(img, "png", new File("Test.png")); }
From source file:Main.java
public static void main(String args[]) throws Exception { BufferedImage img1 = ImageIO.read(new File("c:/Java_Dev/1.png")); BufferedImage img2 = ImageIO.read(new File("c:/Java_Dev/2.png")); BufferedImage joinedImg = joinBufferedImage(img1, img2); ImageIO.write(joinedImg, "png", new File("c:/Java_Dev/joined.png")); }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedImage inputFile = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); for (int x = 0; x < inputFile.getWidth(); x++) { for (int y = 0; y < inputFile.getHeight(); y++) { int rgba = inputFile.getRGB(x, y); Color col = new Color(rgba, true); col = new Color(255 - col.getRed(), 255 - col.getGreen(), 255 - col.getBlue()); inputFile.setRGB(x, y, col.getRGB()); }/*from w w w . j a va 2s . c o m*/ } File outputFile = new File("invert.png"); ImageIO.write(inputFile, "png", outputFile); }
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 w ww . j av a 2 s . c o m*/ ImageIO.write(bdest, "JPG", new File("b.jpg")); }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedImage bufferedImage = ImageIO.read(new File("a.jpg")); BufferedImage destinationBufferedImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g = destinationBufferedImage.createGraphics(); AffineTransform at = AffineTransform.getScaleInstance(2, 2); g.drawRenderedImage(bufferedImage, at); ImageIO.write(destinationBufferedImage, "JPG", new File("b.jpg")); }
From source file:Main.java
public static void main(String[] args) throws java.io.IOException { BufferedImage img = ImageIO.read(new File("input-image.png")); BufferedImage rotated = new AffineTransformOp( AffineTransform.getQuadrantRotateInstance(3, img.getWidth() / 2, img.getHeight() / 2), AffineTransformOp.TYPE_BILINEAR).filter(img, null); ImageIO.write(rotated, "PNG", new File("output-image.png")); }
From source file:Main.java
public static void main(String args[]) throws IOException { File file = new File("your_file.jpg"); BufferedImage image = ImageIO.read(file); int x = 10;/*from w w w . j av a 2 s . c o m*/ int y = 10; int clr = image.getRGB(x, y); int red = (clr & 0x00ff0000) >> 16; int green = (clr & 0x0000ff00) >> 8; int blue = clr & 0x000000ff; System.out.println("Red Color value = " + red); System.out.println("Green Color value = " + green); System.out.println("Blue Color value = " + blue); }