Pasting an Image from the clipboard
in
Programming Questions
•
1 year ago
Hello! I'm new here so please bear with me if I am not following standard conventions for these forums (and please tell me so that I can learn!).
So, I need to be able to paste an image from the clipboard into my Processing application, and manipulate it as a PImage. I did a quick Google search which yielded me this:
http://processing.org/discourse/beta/num_1272633686.html
That solution looks good and I don't see any problems with it, but for whatever reason, I get this runtime error:
- Exception in thread "Animation Thread" java.lang.ClassCastException: [I cannot be cast to [B
- at sun.awt.image.ByteInterleavedRaster.getDataElements(Unknown Source)
- at processing.core.PImage.<init>(Unknown Source)
- at sketch_120822b.GetImageFromClipboard(sketch_120822b.java:75)
- at sketch_120822b.keyPressed(sketch_120822b.java:59)
- at processing.core.PApplet.handleKeyEvent(Unknown Source)
- at processing.core.PApplet.dequeueKeyEvents(Unknown Source)
- at processing.core.PApplet.handleDraw(Unknown Source)
- at processing.core.PApplet.run(Unknown Source)
- at java.lang.Thread.run(Unknown Source)
The line it points to is
- img = new PImage(image);
I tried several other solutions for Java which also gave the same results.
I am running 64 bit Linux with Oracle's JDK 7u6 and Processing is configured to use this system Java. Thanks for the help!
1