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();
火曜日, 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:
PHP: Composer の使い方
PHP には Composer という優れたパッケージ管理ツールがあります。最近、PHP サイトを Composer を使って再構築する作業を行いましたので、方法を書いておきたいと思います。 Composerとは? ComposerはPHPのパッケージ管理ツールです。Py...
-
Qt はまってます。Mac でも書いたアプリがコンパイルできて、しっかり動くのを確認しました。このあいだ Chitubox が Qt 使ってるのを知ってうれしかったです。 Mac でもそのまま動くんですが、アプリのアイコンの設定はプラットフォーム依存です。 公式マニュアルでも設定...
-
コンデンサマイク 極性があります コンデンサマイクがようやく届きました。モジュールではないのでそのままでは信号が弱いので使えません。信号を増幅する必要があります。 ちょっとした手間ですが、首尾よく動いてくれました。この回路の応用で、使えるマイクが出来ます。 ...
-
Flask/SQLAlchemy 使ってる方、jinja で困ってませんか? 本体で Python の関数を書いてもいいんですが、テンプレートでも関数が呼べます。 日付を出したい場合、フォーマットなら strftime() が使えます。 わざわざ文字列を作って渡す必...