How to export to High-res document? l

edited March 2015 in How To...

So ive got this code, but im not sure how to create high-res screenshots or export as a pdf in high resolution. Any help is largely appreciated.

    import ddf.minim.analysis.*; 
    import ddf.minim.*;
    import java.awt.Robot;
    import java.awt.*;
    import java.awt.image.*;

    Minim minim; 
    AudioInput in; 
    FFT fft; 
    PImage screenShot;
    int colmax = 1000;                           // larger = slower, smaller = quicker   // each column is a segment in time
    int rowmax = 1000;                           // should be the same as your fft specSize()  too large and you have redundant info, too small and data gets smooshed together
    int[][] sgram = new int[rowmax][colmax];     // [freq][samples]
    int col;                                     // keep track of which column we are on 

    int radius = 300;                            //radius of the 'spinner'
    PVector[] scr2pol;                           //holds the polar coordinates of the screen coordinates

    void setup() { 
      size(1200, 800);

      noStroke(); 
      smooth(); 
      minim = new Minim(this);                           // Minim stuff
      in = minim.getLineIn(Minim.STEREO, 2048);
      fft = new FFT(in.bufferSize(), in.sampleRate()); 
      fft.window(FFT.HAMMING);

      scr2pol = screenToPolar(width/2,height/2);   // creates a look up table for a circle at some point x, y
    }

    void draw() { 
    background(0); 
    noStroke();
    fill(#FFFFFF, 20);
     fill(-1, 10);
      stroke(-1, 50);
      fft.forward(in.mix);
      // removed old drawing stuff since we are now drawing it differently
      for (int i = 0; i < rowmax ; i++) {
       int sp = (int)(i*fft.specSize()/rowmax); 
        sgram[i][col] = (int)Math.round(Math.max(0, 40*Math.log10(1000*fft.getBand(sp))));       // this is where you set the value of what will be drawn
      }
      if (++col >= colmax) col = 0;

      // This goes through every screen pixels (cartesian coordinates) and looks up the relative value in the sgram (as polar coordinates)
      loadPixels();
      for (int y = 0; y < height; y++) {               // You could make this so it only is the size of the area that will be drawn, but this isn't too slow                  
        for (int x = 0; x < width; x++) {
          int index = x+y*width;                       // x y to image index.              
          if (scr2pol[index] != null) {                // if this pixel has a corresponding polar cordinate that is in sgram 
                                                       // the values in the polar coordinates array were set to null if that point would be outside the sgram array 
            int col = sgram[(int)scr2pol[index].x][(int)scr2pol[index].y];      // set it to the value in sgram at x, y
            pixels[index] = color(col);                // draw a point            
          }
        }
      }
      updatePixels();
    }

    public PVector[] screenToPolar(int xc, int yc) {        // create an array so values aren't recalculated every time
      PVector[] result = new PVector[width * height];
      for (int y = 0; y < height; y++) {                   
        for (int x = 0; x < width; x++) {
          float ang = (int)((atan2(y-yc, x-xc)+PI)*colmax/TWO_PI);      // angle to point x,y from xc, yc Converted to columns in sgram
          float dis = dist(x,y,xc,yc)*rowmax/radius;                    // distance                       Converted to rows in sgram
          if (dis >= 0 && dis < rowmax && ang >= 0 && ang < colmax) {   // only create the data if it isn't outofbounds of sgram
            result[x+y*width] = new PVector (dis,ang);                  
          }
        }
      }
      return result;
    }


    void stop() {  
      in.close(); 
      minim.stop();
      super.stop();
    }

Answers

  • Only example I've got is from this forum thread:
    http://forum.processing.org/two/discussion/8025/take-a-screen-shot-of-the-screen

    Dunno whether it's hi-res quality or not though! :-??

  • @clarksonthomas== i had this problem and tried a lot of solutions which do not work (or only seem to do so, as for example if you create a great graphics, scale and so on: it creates a great picture but not in high res); finally i decided to work with a size() calculated according to high res, let us say size(6000,5000); of course this choice is not good for the frame rate, but after saving() in the classical way you get a picture that you can resize (dividing it) in photoshop to 300 dpi...Yet, of course, you have also to multiply all your values if you want that the graphics be accorded to the size()... happy if someone finds some better way!

  • @GoToLoop::

    this is useless for highres saving... (i have not seen your answer before, excuse me!)

Sign In or Register to comment.