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 & HelpSyntax Questions › Saving an image with 300+ dpi...
Page Index Toggle Pages: 1
Saving an image with 300+ dpi... (Read 495 times)
Saving an image with 300+ dpi...
Mar 1st, 2007, 5:54am
 
Can somebody explain to me how I can capture an image from a processing application with more than 300 dpi's? What I need to do is capture an image that will print out at a very large size. I could maybe do it using the PDF library but I have not been able to get it to work. I'm very new at this and if somebody could give me a hand, i'd really appreciate it:

Here's the code I've been messing with

/**
Click and/or drag to spawn life<br>
Press 'r' to fill randomly<br>
Press 'z' to decrease spawn rate (die out faster overall)<br>
Press 'x' to increase spawn rate (die out slower overall)<br>
Press space to clear<br>
*/

NotLifeCA ca;
Palette pal;
float spawnRate = 0.25;

void setup() {
 size(900,900, P3D);
 ca = new NotLifeCA();
 pal = new Palette("pat.gif");
 background(#ffffff);
loadPixels();
}

void draw() {
  if (mousePressed && mouseButton==LEFT) {
   ca.spawn(mouseX/2,mouseY/2);
 }
 ca.move();
 ca.draw(pal);
}

void keyPressed() {
 if (key=='`') saveFrame("frame.tga");
 if (key==' ') { ca.wipe(); background(#ffffff); }
 if (key=='r') { ca.create(); background(#ffffff); }
 if (key=='z') { if (spawnRate > 0.20) spawnRate -= 0.01; }
 if (key=='x') { if (spawnRate < 0.30) spawnRate += 0.01; }
}

class Palette {
 color [] colors;
 Palette(String filename) {
   colors = new color[256];
   PImage img = loadImage(filename);
   for (int i=0; i<256; i++)
     colors[i] = img.pixels[i];
 }
 color getColor() {
   return getColor((int)(random(256)));
 }
 color getColor(int i) {
   if (i<0) i=0;
   else if (i>255) i=255;
   return colors[i];
 }
}

class NotLifeCA {
 static final int maxlife = 63;
 int cols, rows;
 int [][] cells;
 NotLifeCA() {
   cols = width/2;
   rows = height/2;
   cells = new int[rows][cols];
   wipe();
 }
 void wipe() {
   for (int r=0; r<rows; r++)
     for (int c=0; c<cols; c++)
       cells[r][c] = 0;
 }
 void create() {
   for (int r=0; r<rows; r++)
     for (int c=0; c<cols; c++)
       cells[r][c] = (random(1.0)<0.999) ? 0 : maxlife;
 }
 void spawn(int c, int r) {
   if ((c>=0) && (c<cols) && (r>=0) && (r<rows))
     cells[r][c] = maxlife;
 }
 void move() {
   for (int r=0; r<rows; r++) {
     for (int c=0; c<cols; c++) {
       int cell = cells[r][c]--;
       if (cell==maxlife-1) {
         for (int rr=-1; rr<2; rr++) {
           int rrr = r + rr;
           if (rrr<0) rrr += rows;
           else if (rrr>=rows) rrr-=rows;
           for (int cc=-1; cc<2; cc++) {
             int ccc = c + cc;
             if (ccc<0) ccc += cols;
             else if (ccc>=cols) ccc -= cols;
             if (random(1.0) < spawnRate) {
               if (cells[rrr][ccc] < 0) {
                 cells[rrr][ccc] = maxlife;
               }
             }
           }
         }
       }
     }
   }
 }
 void draw(Palette pal) {
   int index = 0;
   for (int r=0; r<rows; r++) {
     for (int c=0; c<cols; c++) {
       int cell = cells[r][c];
       if (cell >= 0) {
         pixels[index] = pal.colors[cell<<2];
                }
       index+=2;
     }
     index += width;
   }
 updatePixels();
 }
}
Page Index Toggle Pages: 1