Hello,

I have the following paintComponent() method inside of a JPanel. It paints
a histogram. I would like to retrieve a buffered image of the result to
modify.

  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2 = (Graphics2D) g;

    // returns the width and height of the Jpanel
    // could of used this.getWidth(); but not necessary
    int width = getWidth();
    int height = getHeight();
    int max = this.maxVal();
    g2.setColor(Color.black);
    g2.drawLine(0, height+1, width, height+1);

    if (max!=0) {
      for (int i =0; i < hist.length; i ++) {
        g2.drawLine((i*width)/hist.length,height,
                   (i*width)/hist.length,height - (height*hist[i])/max);
      }
    }


**** I then tried doing it like this, but it returns a null buffered image
****


    this.bimg = new BufferedImage(720,576,BufferedImage.TYPE_3BYTE_BGR);
    g2.drawImage(bimg,0,0,null);
  }


Any help appreciated,
sean

===========================================================================
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".

Reply via email to