Manipulating and Displaying Images in Java Lihang Ying Department of Computing Science University of Alberta, Canada
Display an image Image img = getImage(getURL("images/test.jpg")); BufferedImage bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB); Graphics2D big = bi.createGraphics(); big.drawImage(img,0,x,y);
Manipulate pixels Class BufferedImage int getRGB(int x, int y)getRGB void setRGB(int x, int y, int rgb)setRGB void setData(Raster r) Sets a rectangular region of the image to the contents of the specified Raster r.setDataRaster Class WritableRaster extend Raster A class representing a rectangular array of pixels. voidsetPixel(int x, int y, float[] fArray)setPixel …
Image-filter operations(1)
Image-Filter Operations(2) public static final float[] SHARPEN3x3 = { 0.f, -1.f, 0.f, -1.f, 5.0f, -1.f, 0.f, -1.f, 0.f}; BufferedImage dstbimg = new BufferedImage(iw,ih,BufferedImage.TYPE_INT_R GB); Kernel kernel = new Kernel(3,3,SHARPEN3x3); ConvolveOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); cop.filter(srcbimg,dstbimg);
References Tutorial image.fm.html# image.fm.html#65661 Java API mage/BufferedImage.html mage/BufferedImage.html mage/Raster.html mage/Raster.html