火曜日, 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();

PHP: Composer の使い方

PHP には Composer という優れたパッケージ管理ツールがあります。最近、PHP サイトを Composer を使って再構築する作業を行いましたので、方法を書いておきたいと思います。 Composerとは? ComposerはPHPのパッケージ管理ツールです。Py...