ColorReducer イメージ減色処理・Javaの小技、サンプル、ニュースなどを紹介していきます。みんなで参考にしてください。

Ads by Google


上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

ColorReducer イメージ減色処理


このサンプルでは256色に減色しています。
減色処理はJimiの ColorReducer を使用します。
Jimiのライブラリは以下からダウンロードしてください。
http://java.sun.com/products/jimi/


Image image = 減色するイメージ
ColorReducer reducer = new ColorReducer(256);
Image reduced = reducer.getColorReducedImage(image);
int width=image.getWidth();
int height=image.getHeight();
BufferedImage bimg = new BufferedImage(width,height,BufferedImage.TYPE_BYTE_BINARY);
Graphics gr = bimg.createGraphics();
gr.drawImage(reduced,0,0,null);
image = bimg;