CGContextFlush: invalid context with awt.Toolkit and awt.Graphics
Anyone have any idea whatsoever what this is all about.
This is more or less the graphic part of the program
I'm using
to load the image and
to draw it in a subclass of java.awt.Frame.
The image is a 40x40 png created with Pixen 3.0.
The strange thing is that the first time I attempt to draw the image I will always get a "CGContextFlush: invalid context" message in the console, however, if I use getBufferStrategy().show() again it will paint the image without complaints, most of the times at least.
Sometimes it just refuses to draw anything at all.
Should point out that it's only the images loaded with Toolkit.createImage that behaves strangely, any graphic operation used on Images created with Component.createImage works fine and without any errors.
Anyone got any idea of what this is all about?
Thankful for any suggestions or input.
Here is a working code if anyone feel like testing what happens.
Not a pice of art but it should get the work done, the loop will repaint the image.
This is more or less the graphic part of the program
I'm using
Code:
Image i = Toolkit.getDefaultToolkit().createImage(AbsoluteImagePath);Code:
getBufferStrategy().getDrawGraphics().drawImage(i, 100, 100, this);
getBufferStrategy().show();The image is a 40x40 png created with Pixen 3.0.
The strange thing is that the first time I attempt to draw the image I will always get a "CGContextFlush: invalid context" message in the console, however, if I use getBufferStrategy().show() again it will paint the image without complaints, most of the times at least.
Sometimes it just refuses to draw anything at all.
Should point out that it's only the images loaded with Toolkit.createImage that behaves strangely, any graphic operation used on Images created with Component.createImage works fine and without any errors.
Anyone got any idea of what this is all about?
Thankful for any suggestions or input.
Here is a working code if anyone feel like testing what happens.
Code:
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
public class LekMedToolkitImage extends Frame {
/**Loads and display a Image file.
@args filename the filename of the image file(with extension).*/
public LekMedToolkitImage(String filename) {
super();
setSize(400, 300);
setVisible(true);
createBufferStrategy(2);
File f = new File(filename);
Image i = Toolkit.getDefaultToolkit().createImage(f.getAbsolutePath());
while(true) {
try {
Thread.sleep(100);
} catch(InterruptedException e) {}
getBufferStrategy().getDrawGraphics().drawImage(i, 100, 100, this);
getBufferStrategy().show();
}
}
public static void main(String[] args) {
new LekMedToolkitImage(args[0]);
}
}Not a pice of art but it should get the work done, the loop will repaint the image.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| float FBO on iPhone (invalid operation error) | Fenris | 11 | 2,832 |
Jan 17, 2013 05:40 AM Last Post: Fenris |
|
| Bitmap font toolkit | Najdorf | 9 | 5,689 |
Nov 11, 2008 05:43 PM Last Post: Najdorf |
|
| Full screen context doesn't remain the current context | Malarkey | 3 | 2,975 |
Feb 1, 2007 05:27 PM Last Post: OneSadCookie |
|
| flushing a graphics context in SDL. | dave05 | 1 | 2,631 |
Jun 9, 2005 01:36 PM Last Post: sealfin |
|
| A toolkit for OpenGL | whogben | 7 | 3,364 |
Aug 3, 2003 10:16 AM Last Post: Feanor |
|

