Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement