We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm using and tweaking the code from a sketch that uses 3 images to produce a 3D scene (Three Phase 3D Scanner).
The original code already had a screenshot option but I needed high-resolution outputs and tried to combine some code from this link alexanno.net/2010/06/high-resolution-output-from-processing-processing-in-hd/.
When I press the "s" key it creates two screenshots: one normal and another with high-resolution. The problem is that the high-resolution image doesn't save the image with the perspective I chose with PeasyCam and makes an image with the initial perspective, while the standard screenshot works perfectly with PeasyCam and saves with the perspective I chose before pressing "s".
Can someone help me?
The sketch has 4 files: ThreePhase.pde, Controls.pde, PhaseWrap.pde and PhaseUnwrap.pde I think the problem is in the code of the first one: (I'm sorry for the long code...)
/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/1995*@* */
/* !do not delete the line above, required for linking your tweak if you upload again */
import peasy.*;
import java.applet.*;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.Image;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.util.regex.*;
int inputWidth = 1100;
int inputHeight = 1100;
PeasyCam cam;
float[][] phase = new float[inputHeight][inputWidth];
boolean[][] mask = new boolean[inputHeight][inputWidth];
boolean[][] process = new boolean[inputHeight][inputWidth];
color[][] colors = new color[inputHeight][inputWidth];
boolean update;
void setup() {
size(inputWidth, inputHeight, P3D);
cam = new PeasyCam(this, width/1);
frameRate(60);
stroke(255);
strokeWeight(1);
setupControls();
// phaseWrap();
// phaseUnwrap();
update = true;
}
void draw () {
background(0);
translate(-inputWidth / 2, -inputHeight / 2);
noFill();
int step = 2;
//for (int y = step; y < inputHeight; y += step) {
for (int y = 0; y < inputHeight; y += renderDetail) {
float planephase = 0.5 - (y - (inputHeight / 2)) / zskew;
for (int x = 0; x < inputWidth; x += renderDetail)
// for (int x = step; x < inputWidth; x += step)
if (!mask[y][x]) {
stroke(colors[y][x], 255);
point(x, y, (phase[y][x] - planephase) * zscale);
}
}
if(update) {
phaseWrap();
phaseUnwrap();
update = false;
}
if(takeScreenshot) {
saveFrame(day() + " " + hour() + " " + minute() + " " + second() + ".png");
takeScreenshot = false;
}
}
void HiRes_begin() {
background(0);
strokeWeight(1);
int step = 2;
for (int y = 0; y < inputHeight; y += renderDetail) {
float planephase = 0.5 - (y - (inputHeight / 2)) / zskew;
for (int x = 0; x < inputWidth; x += renderDetail)
if (!mask[y][x]) {
stroke(colors[y][x], 255);
point(x, y, (phase[y][x] - planephase) * zscale);
}
}
}
void keyPressed() {
if (key == 's') {
save("ss_normal.png");
saveHiRes(4);
exit();
}
}
void saveHiRes(int scaleFactor) {
PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, P3D);
beginRecord(hires);
hires.scale(scaleFactor);
HiRes_begin(
);
endRecord();
hires.save("ss_hires.png");
println("Frames saved");
}
Answers
I don't think we can beginRecord() something that has already been drawn in the past! :-&
Thanks for the answer, what you say makes sense. I'm a newbie in this and don't know much about coding...
So what makes sense to me is to call
void draw () {
somewhere in the middle of the last piece of code... after thebeginRecord(hires);
and beforeendRecord();
. I've tried it and I get "unexpected token: void". I guess I can't call a "void" within another "void". :-LHow could this be done?
Is there a way I can delete this last post?
Java's reserved keyword
void
is solely used to define a method that doesn't return anything!We don't call methods prefixing it w/ anything! Otherwise we'd call most of them this way:
I believe that would be the same way how we save PDFs w/ beginRecord().
Check it out some threads about it:
http://forum.processing.org/two/discussion/1584/strange-display-behaviour
http://forum.processing.org/one/topic/pdf-export-shapes-misaligned
http://forum.processing.org/two/discussion/4275/how-to-compile-a-series-of-functions-into-one-variable
-