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 › Tilesaver not working with V. 1.0
Page Index Toggle Pages: 1
Tilesaver not working with V. 1.0 (Read 12227 times)
Tilesaver not working with V. 1.0
Jul 21st, 2009, 11:45pm
 
Just wanted to know if it is known that the tilesaver lib doesnt work under Processing V.1.0x

took me a while to realize that it was not my code. Using Processing 1.48, it just works fine.

This is what happes. Test Image should look like this :
http://files.getdropbox.com/u/1152794/Simple00014_preview.png

but looks like this :
http://files.getdropbox.com/u/1152794/Simple00014_9600x6400.jpg
Re: Tilesaver not working with V. 1.0
Reply #1 - Jul 22nd, 2009, 12:54am
 
It looks like your run your animation until the tilesaver is capturing the screen (for every tile he needs 1 frame respectively a draw() call). Until the tilesaver is running (tileSaver.checkStatus()) you have to stop your animation, but not the drawing. So if you have a function to calculate the position of your circles dont call it when tilesaver is running.
Re: Tilesaver not working with V. 1.0
Reply #2 - Jul 22nd, 2009, 12:56am
 
i dont believe thats the problem... its static and not moving in any way. And the same code works fine in processing 1.48.
Also the camerashifting seems correct when it is done. But i guess there is aproblem with the stitching, looks, like he uses the same images, over and over again.
Re: Tilesaver not working with V. 1.0
Reply #3 - Jul 30th, 2009, 12:16pm
 
No idea? i still didnt solve the problem. Am i the only one?
Re: Tilesaver not working with V. 1.0
Reply #4 - Jul 30th, 2009, 12:52pm
 
Could you show your code, if not too long. Or some simple code showing how to use it?
I downloaded unlekkerLib but I lack a sample sketch to test it and I don't have much time to figure out the API... Smiley
I will at least see if it works for me. Or not.
Re: Tilesaver not working with V. 1.0
Reply #5 - Jul 30th, 2009, 12:57pm
 
good idea, i should test it with an simple test sketch and not the actual one... if the test one is not working ill post the code. Thanks!
Re: Tilesaver not working with V. 1.0
Reply #6 - Jul 30th, 2009, 1:12pm
 
still the same problem. The viewport seems to move correct, so i believe the error happens when stitching together the tiles

Code:

import processing.opengl.*;
import unlekker.util.TileSaver;
import unlekker.geom.Vec3;

TileSaver tiler;

void setup() {
size(500,500,OPENGL);
tiler=new TileSaver(this);
}

void draw () {

if(tiler==null) return; // Not initialized
tiler.pre();

background(0);
colorMode(HSB,100);
randomSeed(0);
stroke(100);
for(int i=0;i<=250;i++){
point(random(width),random(height));
}

noStroke();
lights();
lightSpecular(204, 204, 204);
specular(155, 155, 155);

pointLight(255, 255,255, width/2,height/2,500);


for(int i=0;i<=10;i++){
pushMatrix();
fill(color(random(100),100,100));
noStroke();
translate(random(width),random(height), 0);
sphere(random(70));
popMatrix();

}

tiler.post();
}

void keyPressed() {

if(key=='t') tiler.init("Simple"+nf(frameCount,5),8);
}
Re: Tilesaver not working with V. 1.0
Reply #7 - Jul 30th, 2009, 3:44pm
 
I can only confirm I have the same problem with Windows XP Pro SP3.
Something strange is that when adding tiler.setSaveType(".jpg"); or .png, I get the same file...
If I look at the original code, aTileSaver, the problematic code seems to be at:
Code:
p.loadPixels();  
tileImg.set(idx*p.width, idy*p.height, p.g);

although I am not sure why it does a loadPixels() before set(). Maybe we should hack this code and see if it can be tamed...
Re: Tilesaver not working with V. 1.0
Reply #8 - Jul 30th, 2009, 4:44pm
 
I may be partly to blame...  :(

A while back I had suggested to Marius that he could save memory (and thus allow for larger tilings) by allocating the output image as only a single row of tiles and streaming that out row-by-row to disk.  It's then much easier to tile up to 32K resolution (the limit of most image file formats).  It looks like the "003c" revision of his lib started to implement it but got interrupted.

The "003" version of his library still has the old workable code, it's easy enough to grab just TileSaver.java from the source if you want to patch it that way.

The 003c version is missing a couple things, thus the garbled tile ordering in the output.  If you'd rather fix that version, it'll need minor fixes in three spots:
(the commented line(s) is buggy, followed by corrected line(s))

about line 70: (output image is only one tile high)
   //tileImg=new PImage(p.width*tileNum, p.height*tileNum);
   tileImg=new PImage(p.width*tileNum, p.height);

about line 124: (output image is only 1 tile high, y is always 0)
   //tileImg.set(idx*p.width, idy*p.height, p.g);
   tileImg.set(idx*p.width, 0, p.g);

about lines 196,197: (reverse traversal of rows, now top to bottom)
       //height*((float)tileY/(float)tileNum-.5f)*mod,
       //height*((tileY+1)/(float)tileNum-.5f)*mod,
       height*((float)(tileNum-1-tileY)/(float)tileNum-.5f)*mod,
       height*((tileNum-tileY)/(float)tileNum-.5f)*mod,

Also note the streaming version is limited to tga format output.
Re: Tilesaver not working with V. 1.0
Reply #9 - Aug 16th, 2009, 11:38pm
 
Sorry about the bug, but something strange is going on here. Dave's code is already in the 0003c version, but it doesn't work with 1.0.3 or higher. I did test it with 1.0, but I can't retest since that version is no longer available.

I don't have time to do anything with this right now, but promise to revisit it...
Re: Tilesaver not working with V. 1.0
Reply #10 - Aug 17th, 2009, 10:08pm
 
OK, the unlekkerLib version is definitely broken at the moment and I have no idea what's causing it.

However, the original TileSaver code I posted way back in 2006 still works when pasted into a sketch. I've taken the code posted above and got it working with the old code, so there's something happening with the transition to 1.0.

Here is a ZIP file with a working sketch using the code listed above, obviously it's not a good solution but in desperate times it might just be enough:

TileSaverTest.zip
Re: Tilesaver not working with V. 1.0
Reply #11 - Aug 26th, 2009, 8:22am
 
Just heard of this thread & problem from a friend. I've created an alternative tiler class (based on the one by Marius) which I only recently also extended to support different FOVs and clipping planes. It was meant to be part of toxiclibs for a while now, but I've been holding off it (to avoid the dependencies) and will include it in a Processing adapter bundle for this and various other classes in the collection soon.

Below is a working demo (works in 1.0.6) and the already adapted Tiler class itself.

Hope that helps!

Code:
import processing.opengl.*;

import toxi.geom.*;

Tiler tiler;

// camera field of vision and desired clipping planes
float FOV=radians(90);
float CLIP_NEAR=1;
float CLIP_FAR=5000;

int NUM_TILES=3;

void setup() {
size(640,480,OPENGL);
tiler=new Tiler((PGraphics3D)g,NUM_TILES);
}

void draw() {
perspective(FOV,(float)width/height,CLIP_NEAR,CLIP_FAR);
translate(width/2,height/2,0);
background(0);
noStroke();
tiler.pre();
lights();
rotateX(0.3);
rotateY(0.2);
for(int y=0; y<6; y++) {
for(int x=0; x<6; x++) {
pushMatrix();
translate((x-3)*300,(y-3)*300,0);
fill(y*64,x*16,(6-x)*64);
box(200);
popMatrix();
}
}
tiler.post();
}

void keyPressed() {
tiler.initTiles(FOV,CLIP_NEAR,CLIP_FAR);
tiler.save(sketchPath("export"), "tiles-" + (System.currentTimeMillis() / 1000), "tga");
}

/**
* Implements a screen tile exporter with support for FOV,
* clip planes and flexible file formats.
*
* Re-engineered from an older version by Marius Watz:
* http://workshop.evolutionzone.com/unlekkerlib/
*
* @author toxi <info at postspectacular dot com>
*/
class Tiler {
protected PGraphics3D gfx;
protected PImage buffer;
protected Vec2D[] tileOffsets;
protected double top;
protected double bottom;
protected double left;
protected double right;
protected Vec2D tileSize;

protected int numTiles;
protected int tileID;
protected float subTileID;

protected boolean isTiling;
protected String fileName;
protected String format;
protected double cameraFOV;
protected double cameraFar;
protected double cameraNear;

public Tiler(PGraphics3D g, int n) {
gfx = g;
numTiles = n;
}

public void chooseTile(int id) {
Vec2D o = tileOffsets[id];
gfx.frustum(o.x, o.x + tileSize.x, o.y, o.y + tileSize.y,
(float) cameraNear, (float) cameraFar);
}

public void initTiles(float fov, float near, float far) {
tileOffsets = new Vec2D[numTiles * numTiles];
double aspect = (double) gfx.width / gfx.height;
cameraFOV = fov;
cameraNear = near;
cameraFar = far;
top = Math.tan(cameraFOV * 0.5) * cameraNear;
bottom = -top;
left = aspect * bottom;
right = aspect * top;
int idx = 0;
tileSize = new Vec2D((float) (2 * right / numTiles), (float) (2 * top / numTiles));
double y = top - tileSize.y;
while (idx < tileOffsets.length) {
double x = left;
for (int xi = 0; xi < numTiles; xi++) {
tileOffsets[idx++] = new Vec2D((float) x, (float) y);
x += tileSize.x;
}
y -= tileSize.y;
}
}

public void post() {
if (isTiling) {
subTileID += 0.5;
if (subTileID > 1) {
int x = tileID % numTiles;
int y = tileID / numTiles;
gfx.loadPixels();
buffer.set(x * gfx.width, y * gfx.height, gfx);
if (tileID == tileOffsets.length - 1) {
buffer.save(fileName + "_" + buffer.width + "x"
+ buffer.height + "." + format);
buffer = null;
}
subTileID = 0;
isTiling = (++tileID < tileOffsets.length);
}
}
}

public void pre() {
if (isTiling) {
chooseTile(tileID);
}
}

public void save(String path, String baseName, String format) {
(new File(path)).mkdirs();
this.fileName = path + "/" + baseName;
this.format = format;
buffer = new PImage(gfx.width * numTiles, gfx.height * numTiles);
tileID = 0;
subTileID = 0;
isTiling = true;
}

public boolean isTiling() {
return isTiling;
}
}
Re: Tilesaver not working with V. 1.0
Reply #12 - Apr 21st, 2010, 7:46am
 
Hello, How can I modify this code above to work with 2D images? (sorry im still a newb at exporting large images). Thanks!
Re: Tilesaver not working with V. 1.0
Reply #13 - Apr 21st, 2010, 8:05am
 
This code is useful only in OpenGL mode.
All the image data is still managed in memory.
Just set higher memory settings in Processing.
Re: Tilesaver not working with V. 1.0
Reply #14 - May 17th, 2010, 9:42am
 
I'm having trouble with strokes - lines look fine on the screen, but simply aren'r rendered in the tiled version - even when I boost the strokeWeight and fill alpha of the lines - anybody bumped into similar issues? (my code uses opengl additive blending, but the problem persists when I turn it off too)

Also, is this the most up-to-date tileSaver code? (compared to the one in toxiclibs)
Page Index Toggle Pages: 1