giovedì 4 ottobre 2012

Crea PNG in Java

Per creare una immagine e salvarla in formato PNG in Java si usano le Buffered Images



L'esempio sotto riportato e' sostanzialmente autoesplicativo
-----------------------------------------

package com.test.png;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Scrivi {

private static BufferedImage bimage;

public static void main(String[] args) {
bimage = new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
int rgb = 0xFF00FF00;
for (int s=10;s<90;++s) bimage.setRGB(s, s, rgb);

File f = new File("/home/luca/immagine_java.png");
try {
ImageIO.write(bimage, "PNG", f);
} catch (IOException e) {

e.printStackTrace();
}
}

}

Nessun commento:

Posta un commento

Physics informed neural network Fukuzono

Visto che puro ML non funziona per le serie tempo di cui mi sto occupando ed le regressioni basate su formule analitiche mostrano dei limiti...