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 & HelpPrograms › Drawing to the processing window
Page Index Toggle Pages: 1
Drawing to the processing window (Read 557 times)
Drawing to the processing window
Apr 25th, 2008, 3:35pm
 
Hi all,

I wonder if someone can point me in the right direction for information on how one would use java to draw to/manipulate the processing window as a buffer ? Is it possible to use java to write to a screen memory space ?
Re: Drawing to the processing window
Reply #1 - Apr 25th, 2008, 3:46pm
 
So far I have some references to buffers in Java:

http://java.sun.com/j2se/1.5.0/docs/api/java/nio/package-summary.html

...and the possibility to write pixels to bitmaps as backbuffers for double buffering-type operations.
Re: Drawing to the processing window
Reply #2 - Apr 25th, 2008, 5:12pm
 
I'm not quite sure what you're trying to do. All processing applets are double-buffered by default, and processing has many methods for putting pixels and images on screen..
Re: Drawing to the processing window
Reply #3 - May 1st, 2008, 5:47pm
 
What I am actually trying to do is manage transformations independently on several displayed images...

Since scale and translate are commutative I am trying to apply a transformation, write the image to a buffer reset the matrix and then repeat to get a new bitmap containing all of my independently transformed images.

To do this quickly I need to implement some kind of blitting as opposed to simply iteratively copying the pixeldata.

Perhaps I'm going about this in a stupid way ?
Re: Drawing to the processing window
Reply #4 - May 1st, 2008, 5:54pm
 
I think that I could use arraycopy on the pixeldata to blit...
Re: Drawing to the processing window
Reply #5 - May 1st, 2008, 5:58pm
 
It's still a bit vague.. there's pushMatrix() and popMatrix() to do the resetting of the matrix, meaning you can just do:

Code:
pushMatrix();
translate(...);
rotate(...);
image(image1,x,y);
popMatrix();
pushMatrix();
translate(..some other..);
rotate(..an angle..);
image(image2,x,y);
popMatrix();
//etc etc


that'll let you treat each image individually, and end up with them all on screen individually translated/rotated.
Re: Drawing to the processing window
Reply #6 - May 1st, 2008, 7:39pm
 
OMG,

Thanks john, I just realised looking at your code that I have been calling image in the wrong place, I can't believe how blinkered I was getting! Such a relief to move away from hardcore solutions Smiley I owe you one.
Page Index Toggle Pages: 1