Java で画像を BufferedImage に変換する
このチュートリアルでは、画像タイプを BufferedImage に変換する最も簡単な方法を見ていきます。キャスト(BufferedImage) image; は動作しませんが、パラメータ:- Length: img.getWidth()
- Height: image.getHeight()
- ピクセルと色: BufferedImage.TYPE_INT_ARGB.
変換は非常に簡単です。BufferedImage スーパーから継承 Image class.
public static BufferedImage toBufferedImage(Image img)TYPE_INT_ARGB は、8 ビット RGB (RGB) タイプのイメージを表します。アルファレンダリングと透明度パラメータをサポートします クラスの alphaComposite.
{
//画像がBufferedImage型の場合
//その後、キャストのみ
//渡された画像はBufferedImage型であるため
if (img instanceof BufferedImage)
{
return (BufferedImage) img;
}
// BufferedImageを作成します
BufferedImage bufimage = new BufferedImage(img.getWidth(null),
img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
bufimage を返します。
}
References:
http://stackoverflow.com/questions/221830/set-bufferedimage-alpha-mask-in-java