网上有对他的简介很多,这不废话了,看看是怎么用,根据起自带的一些demo,简单说明下java对图片的处理
下载相应包(JimiProClasses.zip)并加到classpath,是个zip文件;
1.简单处理
这样处理的结果图片变小了,效果却还可以,肉眼感觉不出
============================================================================================================================================
2. ColorReduce对图片颜色的降低处理
1)先准备一张图片,方便测试,放在与java文件同目录下
2)写代码ColorReduceTest.java
这里主要用到com.sun.jimi.core.util.ColorReducer这个类,在起demo中有错误,多了个util,去了就可以了;
ColorReducer 方法的介绍
2个构造方法
ColorReducer
public ColorReducer(int maxColors)Creates a ColorReducer to perform color reduction on an Image without any dithering.
Parameters:
maxColors - the maximum number of colors in the reduced image
--------------------------------------------------------------------------------
ColorReducer
public ColorReducer(int maxColors,
boolean dither)Creates a ColorReducer to perform color reduction on an Image.
Parameters:
maxColors - the maximum number of colors in the reduced image
dither - true if the image should be dithered to create smoother results
其他方法
getColorReducedImageProducer
public java.awt.image.ImageProducer getColorReducedImageProducer(java.awt.image.ImageProducer producer)
throws JimiException
Perform color reduction.
Parameters:
producer - the ImageProducer to draw image data from
--------------------------------------------------------------------------------
getColorReducedImageProducer
public java.awt.image.ImageProducer getColorReducedImageProducer(java.awt.Image image)
throws JimiException
Perform color reduction.
Parameters:
image - the Image to draw image data from
-------------------------------------------------------------------------------
getColorReducedImage
public java.awt.Image getColorReducedImage(java.awt.image.ImageProducer producer)
throws JimiException
Perform color reduction.
Parameters:
producer - the ImageProducer to draw image data from
--------------------------------------------------------------------------------
getColorReducedImage
public java.awt.Image getColorReducedImage(java.awt.Image image)
throws JimiException
Perform color reduction.
Parameters:
image - the Image to draw image data from
--------------------------------------------------------------------------------
doColorReduction
protected JimiRasterImage doColorReduction(java.awt.image.ImageProducer producer)
throws JimiException
#完#
---------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
二、
把gif图片处理成png
1.准备图片
2.编写代码
经过max压缩,文件缩小了些,清晰度却肉眼没有感觉到变化
更多说明请看api
=============================================================================================================================================