火曜日, 1月 27, 2009

ImageIO.write(): To save transparent PNG image files

The ImageIO class and its write method that comes with JDK1.60 does not support writing out transparent GIF images (at least in the way shown below). The write method of the class won't write out proper GIF format files with a transparent color. The method will create PNG files all right. The following shows how to save an image file. Suppose you have (BufferedImage)bufferedImage that you want to save:



FileOutputStream out=new FileOutputStream(fileName);
String descriptor="PNG";
BufferedImage image=new BufferedImage(right-left,bottom-top,BufferedImage.TYPE_INT_ARGB);
Graphics2D g=(Graphics2D)image.getGraphics();
g.drawImage(bufferedImage,0,0,right-left,bottom-top,left,top,right,bottom,this);
g.dispose();
ImageIO.write(image,descriptor,out);
out.flush();

RP2040 Zero で MicroPython を使う

  埋め込み用マイコンでも Python を動かせる MicroPython というものがあります。 リアルタイムでコマンドラインからマイコンを動かせる画期的なシステムなので、ちょっとした感動が味わえます。 使い方としては、まずファームウエアをアップロードしてドライブとして認識さ...