saveFrame trips ClassCastException on Raspberry Pi
in
Integration and Hardware
•
2 months ago
I am helping some middle-school kids learn math, physics, and programming on Raspberry Pi computers (they love them!) and I would like for them to be able to hit 'p' during execution to drop a frame to a file. This is using 2.0b8 on raspbian. Here is the requisite code:
- void keyPressed() {
- if (key == 'p') {
- saveFrame();
- //saveFrame("img_vortex_#####.jpg"); // just as unsuccessful
- }
- }
But this is the error that I get:
- Exception in thread "Animation Thread" java.lang.ClassCastException: [I cannot be cast to [S
- at sun.awt.image.ShortInterleavedRaster.getDataElements(ShortInterleavedRaster.java:293)
- at processing.core.PGraphicsJava2D.loadPixels(PGraphicsJava2D.java:2308)
- at processing.core.PImage.save(PImage.java:3209)
- at processing.core.PApplet.saveFrame(PApplet.java:4063)
- at vortex_advanced.keyPressed(vortex_advanced.java:95)
- at processing.core.PApplet.keyPressed(PApplet.java:3339)
- at processing.core.PApplet.handleKeyEvent(PApplet.java:3157)
- at processing.core.PApplet.dequeueEvents(PApplet.java:2606)
- at processing.core.PApplet.handleDraw(PApplet.java:2277)
- at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243)
- at processing.core.PApplet.run(PApplet.java:2140)
- at java.lang.Thread.run(Thread.java:722)
Any ideas how I can successfully trigger a frame dump to a file?
Mark
1