GENERATION LOSS.

Open the last saved jpeg image
Save it as a new jpeg image with slightly more compression
Repeat 600 times

http://hadto.net/category/sketchbook/generation-loss

import com.sun.image.codec.jpeg.*;

PImage img;
int numberOfFrames = 600;

void setup()
{
  size(1024,768);
}

void draw()
{
  for(int i =1; i < numberOfFrames ; i++)
  {
    PImage reference = loadImage("sky"+(i-1)+".jpg");
    image(reference,0,0);
    BufferedImage img=new BufferedImage(width, height, 
BufferedImage.TYPE_INT_RGB);
    loadPixels();
    img.setRGB(0, 0, width, height, g.pixels, 0, width);
    try{
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
      JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(img);
      float q = map(i,0,numberOfFrames,1,0);
      p.setQuality(q,true);
      encoder.setJPEGEncodeParam(p);
      encoder.encode(img);
      File file = new File(savePath("data/sky"+i+".jpg"));
      FileOutputStream fo = new FileOutputStream(file);
      out.writeTo(fo);
    }
    catch(FileNotFoundException e){
      System.out.println(e);
    }
    catch(IOException ioe){
      System.out.println(ioe);
    }
  }
  exit();
}

_______________________________________________
NetBehaviour mailing list
[email protected]
http://www.netbehaviour.org/mailman/listinfo/netbehaviour

Reply via email to