Java Advanced Imaging相关资料
API: http://www.oracle.com/technetwork/java/jaifaq-138288.html?ssSourceSiteId=otncn#multipage
手册:http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/JAITOC.fm.html
Introduction to Java Advanced Imaging: http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Introduction.doc.html#47285
先关代码
import java.awt.Frame;
import java.awt.image.renderable.ParameterBlock;
import java.io.IOException;
import javax.media.jai.Interpolation;
import javax.media.jai.JAI;
import javax.media.jai.RenderedOp;
import com.sun.media.jai.codec.FileSeekableStream;
import javax.media.jai.widget.ScrollingImagePanel;
/**
* This program decodes an image file of any JAI supported
* formats, such as GIF, JPEG, TIFF, BMP, PNM, PNG, into a
* RenderedImage, scales the image by 2X with bilinear
* interpolation, and then displays the result of the scale
* operation.
*/
public class JAISampleProgram {
String fileName = "C:\\Users\\hejian.DOMRST\\Desktop\\Booklet\\20111024_112457_0001.tiff";
/** The main method. */
public static void main(String[] args) {
/* Validate input. */
if (args.length != 1) {
System.out.println("Usage: java JAISampleProgram " +
"input_image_filename");
System.exit(-1);
}
/*
* Create an input stream from the specified file name
* to be used with the file decoding operator.
*/
FileSeekableStream stream = null;
try {
stream = new FileSeekableStream(args[0]);
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
}
/* Create an operator to decode the image file. */
RenderedOp image1 = JAI.create("stream", stream);
/*
* Create a standard bilinear interpolation object to be
* used with the "scale" operator.
*/
Interpolation interp = Interpolation.getInstance(
Interpolation.INTERP_BILINEAR);
/**
* Stores the required input source and parameters in a
* ParameterBlock to be sent to the operation registry,
* and eventually to the "scale" operator.
*/
ParameterBlock params = new ParameterBlock();
params.addSource(image1);
params.add(2.0F); // x scale factor
params.add(2.0F); // y scale factor
params.add(0.0F); // x translate
params.add(0.0F); // y translate
params.add(interp); // interpolation method
/* Create an operator to scale image1. */
RenderedOp image2 = JAI.create("scale", params);
/* Get the width and height of image2. */
int width = image2.getWidth();
int height = image2.getHeight();
/* Attach image2 to a scrolling panel to be displayed. */
ScrollingImagePanel panel = new ScrollingImagePanel(
image2, width, height);
/* Create a frame to contain the panel. */
Frame window = new Frame("JAI Sample Program");
window.add(panel);
window.pack();
window.show();
}
}
import java.io.File;
import java.io.IOException;
import java.awt.Frame;
import java.awt.image.RenderedImage;
import javax.media.jai.widget.ScrollingImagePanel;
import javax.media.jai.NullOpImage;
import javax.media.jai.OpImage;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.TIFFDecodeParam;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.ImageCodec;
public class MultiPageRead extends Frame {
ScrollingImagePanel panel;
public MultiPageRead(String filename) throws IOException {
setTitle("Multi page TIFF Reader");
File file = new File(filename);
SeekableStream s = new FileSeekableStream(file);
TIFFDecodeParam param = null;
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, param);
System.out.println("Number of images in this TIFF: " +
dec.getNumPages());
// Which of the multiple images in the TIFF file do we want to load
// 0 refers to the first, 1 to the second and so on.
int imageToLoad = 0;
RenderedImage op =
new NullOpImage(dec.decodeAsRenderedImage(imageToLoad),
null,
OpImage.OP_IO_BOUND,
null);
// Display the original in a 800x800 scrolling window
panel = new ScrollingImagePanel(op, 800, 800);
add(panel);
}
public static void main(String [] args) {
String filename = "C:\\Users\\hejian.DOMRST\\Desktop\\Booklet\\20111213133838620.tif";
try {
MultiPageRead window = new MultiPageRead(filename);
window.pack();
window.show();
} catch (java.io.IOException ioe) {
System.out.println(ioe);
}
}
}
分享到:
相关推荐
JAVA处理图片 加文字水印以及灰色透明背景,处理图片。
java 处理图像的明暗度 java 处理图像的明暗度 java 处理图像的明暗度
Java图像处理类库 Java Image Filters
主要为大家详细介绍了java处理图片背景颜色的方法,蓝底寸照批量转换为白底,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
java 处理图片大小等比例缩放;图片裁剪;支持图片压缩不失真;支持图片添加水印;支持动态图的处理;支持自定义图片大小的转换 等 压缩包中内附使用说明
示例代码展示了如何使用Java的图像处理库来对图像进行灰度化处理。在代码中,我们使用javax.imageio.ImageIO类加载输入图像文件,并创建一个与输入图像具有相同尺寸和类型的输出图像。然后,我们遍历输入图像的每个...
java处理图片拼接和添加水印,包含详细注解
java处理图片代码 包括添加水印,剪切图片,文件操作 很好的学习的例子
这是用java写的java 图像处理(模糊处理、锐化处理)源码,和大家一起分享学习
文件内含java 处理图片大小等比例缩放,指定颜色改变颜色。根据不同图片设置阴影图片。
实现java处理图片透明,png图片透明
e123java图像处理java图像处理java图像处理java图像处理java图像处理
JAVA语言编写的小型数字图像处理程序,包含改变采样率、量化等级,显示直方图、直方图均衡、图像旋转、平滑等基本操作
java图像处理相关api介绍及下载地址
java处理图像的几个列子。水印、缩放等图片处理
SimpleImage是阿里巴巴的一个Java图片处理的类库,可以实现图片缩略、水印等处理。 SimpleImage中的ImageRender是图片处理的基类,它是一个抽象类,我们看到,该类中定义了一个抽象方法render(),同时持有一个对...
处理前后台图片旋转问题,前台处理旋转图片展示问题。后台处理旋转图片处理后保存到服务器和数据库问题。
java——图片字体显示方块问题处理 /usr/java/jdk1.7.0_80/jre/lib/fonts/fallback msyhbd.ttf msyh.ttf wqy-microhei.ttf /usr/java/jdk1.7.0_80/lib/fonts/fallback msyhbd.ttf msyh.ttf wqy-microhei.ttf
Java thumbnailator 处理图片(压缩,放大,缩小)