Upload File Form?
              in 
             Programming Questions 
              •  
              7 months ago    
            
 
           
             Is there way to make a form in processing much like the php form found here:
            
             
            
            
            
             
            
            
             
            
            
             
            
            
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
            
             
            
            
             
            
            
             
            
            
 
            
           
             My goal is to create an app that you can upload an image into and it will rearrange the pixels in the image into a spectrum.  There has to be a library somewhere out there that can do this.  
            
            
             Here is my code so Far:
            
            
              PImage img; 
             
             
              int cellsize = 5;
             
             
              int cols, rows; 
             
             
              void setup() {
             
             
                img = loadImage("face.jpeg"); // Load the image;
             
             
                size(img.width, img.height, P3D);
             
             
                cols = width/cellsize;    // Calculate # of columns
             
             
                rows = height/cellsize;    // Begin loop for rows
             
             
              }
             
             
              void draw() {
             
             
                background(245, 245, 245);
             
             
                loadPixels();
             
             
                // Begin loop for columns
             
             
                for (int i = 0; i < cols; i++) {
             
             
                  // Calculate # of rows
             
             
                  for (int j = 0; j < rows; j++) {
             
             
                    int x = i*cellsize + cellsize/2; // x position
             
             
                    int y = j*cellsize + cellsize/2; // y position
             
             
                    int loc = x + y*width; // Pixel array location
             
             
                    color c = img.pixels[loc]; // Grab the color
             
             
                    // Calculate a z position as a function of mouseX and pixel brightness
             
             
                    float r = (mouseX/(float)width*10) * red(img.pixels[loc])-(img.width/2);
             
             
                    float g = (mouseX/(float)width*10) * blue(img.pixels[loc])-(img.width/2);
             
             
                    float b = (mouseX/(float)width*10) * green(img.pixels[loc])-(img.width/2);
             
             
                    pushMatrix(); 
             
             
                    translate(r, g, b);
             
             
                    fill(c);
             
             
                    noStroke();
             
             
                    rectMode(CENTER);
             
             
                    rect(.5*width, .5*height, cellsize, cellsize);
             
             
                    popMatrix();
             
             
                  }
             
             
                }
             
             
              }
             
            
             Remember the point is that instead of:
            
            
             img = loadImage("face.jpeg");
            
            
             ...I would use and upload image function and then what ever image is uploaded would be processed.
            
 
            
              
              1  
            
 
            