1: go to http://java.sun.com/products/java-media/jai/current.html
download java advanced imaging 1.1.2
2: put the lib in your jdk
3: following is the sample i convert my tif to bmp file:
import java.io.fileoutputstream;
import java.io.outputstream;
import java.io.outputstream;
import javax.media.jai.jai;
import javax.media.jai.renderedop;
import javax.media.jai.renderedop;
import com.sun.media.jai.codec.bmpencodeparam;
import com.sun.media.jai.codec.imagecodec;
import com.sun.media.jai.codec.imageencoder;
import com.sun.media.jai.codec.imagecodec;
import com.sun.media.jai.codec.imageencoder;
/*
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
* created on 2004-8-22
*
* todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/
/**
* @author huang jinxiang
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
public class test {
public static void main(string[] args) throws exception{
string inputfile = "me.tif";
string outputfile = "out.bmp";
renderedop src = jai.create("fileload", inputfile);
* @author huang jinxiang
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
public class test {
public static void main(string[] args) throws exception{
string inputfile = "me.tif";
string outputfile = "out.bmp";
renderedop src = jai.create("fileload", inputfile);
outputstream os = new fileoutputstream(outputfile);
bmpencodeparam param = new bmpencodeparam();
imageencoder enc = imagecodec.createimageencoder("bmp", os,
param);
enc.encode(src);
os.close();
}
}
bmpencodeparam param = new bmpencodeparam();
imageencoder enc = imagecodec.createimageencoder("bmp", os,
param);
enc.encode(src);
os.close();
}
}
for more details, you can go & check from :
http://java.sun.com/products/java-media/jai/fordevelopers/jai1_0_1guide-unc/encode.doc.html#47285
反过来你就可以把bmp转成tif的了...
只不过用不同的codec..
只不过用不同的codec..
所以可以在bmp, jpg, png, tif之间相互转换....
闽公网安备 35060202000074号