We are about to switch to a new forum software. Until then we have removed the registration on this forum.
How to copy the out canvas image in the screen without saving image file? I want to edit the image showing in the screen in realtime. Thanks
you can use get()
get(x, y, w, h)
https://www.processing.org/reference/get_.html
PImage c = get( 10,10,30,30 ); image(c, width/2, 0);
not sure if I understood you correctly
Thank you Chrisir! "get()" can only get the image inside the canvas,but I want to get the image outside the canvas. For example, I want to get the "B" content, not "A" content
https://forum.Processing.org/two/discussion/15674/speed-of-screenshots#Item_5
https://forum.Processing.org/two/discussions/tagged?Tag=createscreencapture()
Check this code:
Kf
//REFERENCE: https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html //REFERENCE: http://stackoverflow.com/questions/4490454/how-to-take-a-screenshot-in-java //REFERENCE: https://processing.org/reference/PImage_get_.html //REFERENCE: https://forum.processing.org/two/discussion/9874/how-to-take-control-of-the-mouse-outside-the-sketch-window#latest import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; Robot rbt; boolean loadNow=false; PImage img; void setup() { size(600,600); try { rbt = new Robot(); } catch(Exception e) { e.printStackTrace(); } } void draw() { if(loadNow==true){ img=loadImage("screenshot.jpg"); println(img.width+" "+img.height); image(img.get(200,200,600,600),0,0); //HERE is where you setup the parameters to grab box B as shown in your post. loadNow=false; } } void mouseReleased() { BufferedImage image2 = rbt.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); println("Capturing image..."); try { ImageIO.write(image2, "JPG", new File(("screenshot.jpg"))); println("Saving image..."); loadNow=true; } catch (IOException e) { e.printStackTrace(); } }
Cool!! Thank you kfrajer!
Thank you GoToLoop!
Answers
you can use get()
https://www.processing.org/reference/get_.html
not sure if I understood you correctly
Thank you Chrisir! "get()" can only get the image inside the canvas,but I want to get the image outside the canvas. For example, I want to get the "B" content, not "A" content
https://forum.Processing.org/two/discussion/15674/speed-of-screenshots#Item_5
https://forum.Processing.org/two/discussions/tagged?Tag=createscreencapture()
Check this code:
Kf
Cool!! Thank you kfrajer!
Thank you GoToLoop!