I have a question.... If I have a buffered image. I apply some changes to the image, such as smoothen the image. How can I display the new image. Here is a snippet of my source code. Because everytime I apply the the new image. The only thing is see is my original image. What are the few things to keep in mind to update an image(i.e.)after using setrgb()
[code] class MyPanel extends JPanel { //Purpose: a panel in which to draw //global offscreen and the Graphics2D variable g2 private BufferedImage bufImag; protected Graphics2D g2; private int x,y; final int offScrWidth=1500,offScrHeight=1500; public MyPanel() { bufImag = new BufferedImage(offScrWidth,offScrHeight,BufferedImage.TYPE_INT_RGB); try { InputStream in = new FileInputStream("Skull.JPG"); bufImag = ImageIO.read(in); } catch (IOException ex) {} g2 = bufImag.createGraphics(); setPreferredSize(new Dimension(offScrWidth,offScrHeight)); g2.drawImage(bufImag, 0,0,null); } public void smoothme () { int sum=0; int width=bufImag.getWidth(); int height=bufImag.getHeight(); int[][] pixels = new int[width][height]; int I,J,i,j; for (J=0;J<height;J++) { for (I=0;I<width;I++) { pixels[I][J] = (bufImag.getRGB(I,J)& 0x000000ff); } } bufImag = new BufferedImage(offScrWidth,offScrHeight,BufferedImage.TYPE_INT_RGB); //set of codes for processing the image for (J=0;J<width;J++) { for (I=0;I<height;I++) { bufImag.setRGB(I,J,((pixels[I][J]<<8)+pixels[I][J]<<8)+pixels[I][J]); } } g2.drawImage(bufImag, 0,0,null); repaint(); } public void paintComponent(Graphics g) { //Purpose: do a complete screen refresh here //Input: a Graphics to draw on //Output: changes to the Graphics super.paintComponent(g); Graphics2D g2 = (Graphics2D)g;//copy offscreen to screen g2.drawImage(bufImag, null,0,0); } } class smooth{ // Main class public static void main(String[] args){ MyPanel myPanel=new MyPanel(); MyFrame myFrame=new MyFrame(myPanel); System.out.println("\n\nEnd of Processing"); } } [/code] [Message sent by forum member 'rosh72851' (rosh72851)] http://forums.java.net/jive/thread.jspa?messageID=319250 =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".