BufferedImage is not displayed (all black), but the image may be displayed

I am new to Java graphics (computer graphics in general) and Stack Overflow, so please help me and help me better talk about my problem.

I'm currently trying to display a BufferedImage along with the original image in the Java GUI. This is my code:

Image oriImage = robot.getQwerkController().getVideoStreamService().getFrame(); //load the original image
Graphics2D hi = bufferedImage.createGraphics();
hi.drawImage(oriImage, 0,0, null); //draw the original image into the BufferedImage
hi.dispose();
images[0].put(oriImage, 1); //draws the original image in the first frame
images[1].put(bufferedImage, 2); //draws the BufferedImage in the second frame

and the put function is as follows:

public synchronized void put(Image image, int frameNumber) {
    icon.setImage(image); //sets the image displayed by this icon
    display.paintImageIcon(icon, frameNumber); //paint the image onto the gui
    imageSet = true;
    notifyAll();
}

However, the final graphical interface is as follows

enter image description here

So the image works, but the BufferedImage does not. I would suggest that this works because BufferedImage is a subclass of Image ... Any ideas? Please let me know if additional code is needed ~ Thanks in advance :)

EDIT 1:

, , , bufferedImage Graphics2D , . :

http://i.imgur.com/rJAdp.jpg

. - ( )

2: bufferedImage . , EDIT 1, , drawImage.

3: , while drawImage, ( false, ), !: D

boolean x = false;
while (!x) {
    x = hi.drawImage(oriImage, 0,0, null); //draw the original image into the BufferedImage
}
+5
2

, ImageObserver ( JFrame JPanel, ), drawImage null. .

+1

, , (push). , java (pull).

Java swing/awt : , . repaint().

JPanel paintComponent(Graphics g) g.

. oriImage.getHeight(null), (), ( -1 ).

0

All Articles