本文整理汇总了Java中com.sun.media.jai.codec.SeekableStream类的典型用法代码示例。如果您正苦于以下问题:Java SeekableStream类的具体用法?Java SeekableStream怎么用?Java SeekableStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SeekableStream类属于com.sun.media.jai.codec包,在下文中一共展示了SeekableStream类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.sun.media.jai.codec.SeekableStream; //导入依赖的package包/类
public static void main(String args[]) throws IOException, ImageProcessingException {
String tiffstr = utilities.BrowserDialogs.chooseFile();
InputStream is = new BufferedInputStream(new FileInputStream(tiffstr));
SeekableStream seekstr = new FileCacheSeekableStream(is);
TIFFDirectory tiffdir = new TIFFDirectory(seekstr, 0);
for (int i = 0; i < tiffdir.getNumEntries(); i++) {
// System.out.println(i);
// System.out.println(tiffdir.getField(i));
}
boolean cSB = seekstr.canSeekBackwards();
// System.out.println(cSB);
File tifffile = new File(tiffstr);
getImageTiffMetadata(tifffile);
getExifTiffData(tifffile);
}
开发者ID:friesey,项目名称:preservation-tools,代码行数:18,代码来源:TiffTestClass.java
示例2: read
import com.sun.media.jai.codec.SeekableStream; //导入依赖的package包/类
public static BufferedImage read(File file) throws IOException {
BufferedImage bufferedImage = null;
try {
// We try it with ImageIO
bufferedImage = ImageIO.read(ImageIO
.createImageInputStream(new FileInputStream(file)));
} catch (CMMException ex) {
ex.getCause();
}
if (bufferedImage == null) {
RenderedOp renderedOp = JAI.create("stream", SeekableStream
.wrapInputStream(new FileInputStream(file), true));
if (renderedOp != null) {
bufferedImage = renderedOp.getAsBufferedImage();
}
}
return bufferedImage;
}
开发者ID:Sinouplen,项目名称:CommonTools4J,代码行数:23,代码来源:ImageUtils.java
示例3: resizeImageAsJPG
import com.sun.media.jai.codec.SeekableStream; //导入依赖的package包/类
/**
* This method takes in an image as a byte array (currently supports GIF, JPG, PNG and
* possibly other formats) and
* resizes it to have a width no greater than the pMaxWidth parameter in pixels.
* It converts the image to a standard
* quality JPG and returns the byte array of that JPG image.
*
* @param pImageData
* the image data.
* @param pMaxWidth
* the max width in pixels, 0 means do not scale.
* @return the resized JPG image.
* @throws IOException
* if the image could not be manipulated correctly.
*/
public byte[] resizeImageAsJPG(byte[] pImageData, int pMaxWidth) throws IOException {
InputStream imageInputStream = new ByteArrayInputStream(pImageData);
// read in the original image from an input stream
SeekableStream seekableImageStream = SeekableStream.wrapInputStream(imageInputStream, true);
RenderedOp originalImage = JAI.create(JAI_STREAM_ACTION, seekableImageStream);
((OpImage) originalImage.getRendering()).setTileCache(null);
int origImageWidth = originalImage.getWidth();
// now resize the image
double scale = 1.0;
if (pMaxWidth > 0 && origImageWidth > pMaxWidth) {
scale = (double) pMaxWidth / originalImage.getWidth();
}
ParameterBlock paramBlock = new ParameterBlock();
paramBlock.addSource(originalImage); // The source image
paramBlock.add(scale); // The xScale
paramBlock.add(scale); // The yScale
paramBlock.add(0.0); // The x translation
paramBlock.add(0.0); // The y translation
RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
RenderedOp resizedImage = JAI.create(JAI_SUBSAMPLE_AVERAGE_ACTION, paramBlock, qualityHints);
// lastly, write the newly-resized image to an output stream, in a specific encoding
ByteArrayOutputStream encoderOutputStream = new ByteArrayOutputStream();
JAI.create(JAI_ENCODE_ACTION, resizedImage, encoderOutputStream, JAI_ENCODE_FORMAT_JPEG, null);
// Export to Byte Array
byte[] resizedImageByteArray = encoderOutputStream.toByteArray();
return resizedImageByteArray;
}
开发者ID:aysenurbilgin,项目名称:cww_framework,代码行数:47,代码来源:ImageResize.java
示例4: getSelectedTiffFile
import com.sun.media.jai.codec.SeekableStream; //导入依赖的package包/类
/**
* The <code>getSelectedTiffFile</code> method is used to limit the file
* to the page limit given.
*
* @param tiffFile {@link File} tiff file from which limit has to be applied
* @param pageLimit int
* @throws IOException if file is not found
*/
public static void getSelectedTiffFile(final File tiffFile, final int pageLimit) throws IOException {
OutputStream out = null;
File newTiffFile = null;
if (null != tiffFile && getTIFFPageCount(tiffFile.getAbsolutePath()) > pageLimit) {
try {
final List<BufferedImage> imageList = new ArrayList<BufferedImage>();
final SeekableStream seekableStream = new FileSeekableStream(tiffFile);
final ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", seekableStream, null);
for (int i = 1; i < pageLimit; i++) {
final PlanarImage planarImage = new NullOpImage(decoder.decodeAsRenderedImage(i), null, null, OpImage.OP_IO_BOUND);
imageList.add(planarImage.getAsBufferedImage());
}
seekableStream.close();
final TIFFEncodeParam params = new TIFFEncodeParam();
params.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
String name = tiffFile.getName();
final int indexOf = name.lastIndexOf(IUtilCommonConstants.DOT);
name = name.substring(0, indexOf);
final String finalPath = tiffFile.getParent() + File.separator + name
+ System.currentTimeMillis() + IUtilCommonConstants.EXTENSION_TIF;
newTiffFile = new File(finalPath);
out = new FileOutputStream(finalPath);
final ImageEncoder encoder = ImageCodec.createImageEncoder("tiff", out, params);
params.setExtraImages(imageList.iterator());
encoder.encode(imageList.get(0));
} finally {
if (null != out) {
out.flush();
out.close();
}
}
if (tiffFile.delete() && null != newTiffFile) {
newTiffFile.renameTo(tiffFile);
} else {
if (null != newTiffFile) {
newTiffFile.delete();
}
}
}
}
开发者ID:kuzavas,项目名称:ephesoft,代码行数:49,代码来源:TIFFUtil.java
示例5: loadImageFromBytes
import com.sun.media.jai.codec.SeekableStream; //导入依赖的package包/类
public static RenderedImage loadImageFromBytes(byte[] bytes) throws IOException {
SeekableStream ss = new ByteArraySeekableStream(bytes);
RenderedImage image = JAI.create("stream", ss);
return image;
}
开发者ID:NCIP,项目名称:cagrid-general,代码行数:7,代码来源:ImageUtils.java
示例6: loadImage
import com.sun.media.jai.codec.SeekableStream; //导入依赖的package包/类
PlanarImage loadImage(URL imageURL) throws IOException {
SeekableStream stream = new MemoryCacheSeekableStream(imageURL.openStream());
return JAI.create("stream", stream);
}
开发者ID:tamirhassan,项目名称:pdfxtk,代码行数:5,代码来源:JAIImageFactory.java
注:本文中的com.sun.media.jai.codec.SeekableStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论