RootkitNeo |
|
| Avevo scritto questo source tempo fa per generare immagini PPM, lo condiviso anche con voi. CODICE import java.io.*;
/* * Description: PPM image generator * Author : RootkitNeo * */
class ImagePpm { private byte data[]; private int width,height; ImagePpm(int w, int h) { width = w; height = h; data = new byte[3+(width*height*3)]; } void setPixel(int x,int y, int r, int g, int b) { if(x >=0 && y>=0 && x<=width && y<=height) { data[3*(x+y*width) ] = (byte)r; data[3*(x+y*width)+1] = (byte)g; data[3*(x+y*width)+2] = (byte)b; } } void saveImage(String name) { try { FileOutputStream fos = new FileOutputStream(name+".ppm"); String header="P6\n"+"#Immagine generata da ImagePpm\n"+width+" "+height+"\n255\n"; try { fos.write(header.getBytes("US-ASCII")); fos.write(data); } finally { fos.close(); } } catch(IOException ex) { ex.printStackTrace();} } }
|
| |