We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › FAST SCREENSHOT PRINTING
Page Index Toggle Pages: 1
FAST SCREENSHOT PRINTING (Read 1331 times)
FAST SCREENSHOT PRINTING
Oct 27th, 2007, 12:21pm
 
hi processors,

I am a rookie to processing, but what I want to do is simple.

I want to print out the monitor screen when the mouse is moved, clicked, or any key is pressed.

it is for an installation about digital/analog.

so far with processing it is taking too long. any ideas?

------

/*
This code Prints the stage into the defaule printer device.
It was tested on a PC Windows XP machine, using ***Processing version 91***
(V92 may lock up the application on some machines)

Code adapted for Processing By Ben Fry and Amit Pitaru
on October 15th 2005
 
For a java good example on the Java Printing API, visit this link:
http://www.javacommerce.com/displaypage.jsp?name=printcode.sql&id=18252

Press 'p' to print out the stage non-threaded.
Press 't' to print out the stage as a seperate thread operation.
*/

import java.awt.print.*;

PImage img;

void setup() {
 size(200,200);
 img = loadImage("arch.jpg");
}

void draw() {
 background(255);
 image(img,0,0);
 line(0, 0, 100, 100);
}

void mousePressed() {
// Statements
printStageThreaded();
}
void keyPressed() {
// Statements
printStageThreaded();
}



thank you for helping
Re: FAST SCREENSHOT PRINTING
Reply #1 - Nov 2nd, 2007, 8:02pm
 
If you're using OPENGL (which in your example you were not but you can still switch?) you can get FRAPS or something similar and bind keys for screenshotting. It's usually rather fast.

The method that you're doing will actually halt drawing, so if your nice real-time thing is pausing when screen capturing then I suggest writing a separate thread that saves images in the background, away from your draw() thread.

And if you don't know Threads, look up
http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.html?page=2

(Just in case, I hate it when people assume I know bizarre technical stuff).
Re: FAST SCREENSHOT PRINTING
Reply #2 - Nov 3rd, 2007, 4:51pm
 
you'll need to halt drawing to at least grab the pixels, but the printing and the rest can happen in a separate thread. so the printStageThreaded() should prolly take the results of get() as a parameter, and then take care of the printing separately.

my guess is that you're probably bound by the speed of the os printing api (especially if the threading isn't working correctly yet). if it's a postscript printer, you can also connect to it on port 9100 (i think that's it, i can remember for sure), and spew postscript code to it to make the print happen. basically you'd using processing.net.Client to open up the port, put a little ps header on things, then send the pixels encoded as hex bytes. i don't have the info in front of me but googling around a bit oughta turn up something.
Page Index Toggle Pages: 1