We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Ive made a sketch
I want to output on key press at High Quality. How do you do it when using imported images rather than Co Ordinates?
Ive got a text screen at the beginning and the images are called 'letter' .png. The code makes a collage. I'd like to be able to save individual frames at high res.
PImage [] picArray = new PImage [42];
float r = random (.1, 1);
void setup() {
size (480,777,JAVA2D);
{ textSize(32);
fill(180,75,90);
text("UP ARROW TO GENERATE", 20, 360);
fill(180,75,90);
text("ENTER TO SAVE FRAME ", 20, 400);
}
for (int p = 0; p < picArray.length; p++) {
picArray[p] = loadImage("letter" + nf(p,1) + ".png");
}
}
void draw() {
background(255);
for(int b=0; b<2000; b++){
tint(random(255),random(255));
rotate(random(360));
image(picArray[int(random(picArray.length))], random (width), random (height),r*(1080),r*(720));
}
}
void keyPressed() {
if (keyCode == ENTER){
saveFrame("fragment-####.jpg");
}
}
void mousePressed() {
keyPressed();
}
Answers
I'm not entirely sure what your question is. Do you want to generate a collage, save it if you like it, and then generate a new one?
You are already using imported images...
Sorry - My grammar is terrible.
My sketch uses imported .png files to create a random collage. I would then like to be able to print a high quality size.
On key command the sketch creates a new collage.
Its a collage generator, but i'd like to keep hi res copies of the files clangs generated to print.
thanks, any help is appreciated.
The highest resolution you can get is that of your sketch - 480 x 777 px.
or use a PGraphics off-screen buffer, which can be larger than you desktop, and write to and save that instead.
How do I do that ?
thanks
maybe start by looking at the PGraphics example in the reference.
https://processing.org/reference/PGraphics.html
Of course, however take care as saveFrame() won't work with that.
But you can use save() like this:
pg.save("highRes.png");
(expanding the example from koogs' link)http://processing.github.io/processing-javadocs/core/processing/core/PGraphics.html#save-java.lang.String-
and there's nothing to stop you adding the frame number to the filename yourself to avoid overwriting.
Frame number may not be wise. You can just shift the entire picture saving to setup and remove draw all together. It does speed up things. Also add
surface.setVisible(false)
in the start of setup to remove size and also the slow process of an extra graphics object to render to. Now you just have one - the one you will save.