本文整理汇总了Java中org.apache.commons.imaging.ImageFormats类的典型用法代码示例。如果您正苦于以下问题:Java ImageFormats类的具体用法?Java ImageFormats怎么用?Java ImageFormats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageFormats类属于org.apache.commons.imaging包,在下文中一共展示了ImageFormats类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processImage
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
private byte[] processImage(byte[] imageBytes, List<Rectangle> areasToBeCleaned) {
if (areasToBeCleaned.isEmpty()) {
return imageBytes;
}
try {
BufferedImage image = Imaging.getBufferedImage(imageBytes);
ImageInfo imageInfo = Imaging.getImageInfo(imageBytes);
cleanImage(image, areasToBeCleaned);
// Apache can only read JPEG, so we should use awt for writing in this format
if (imageInfo.getFormat() == ImageFormats.JPEG) {
return getJPGBytes(image);
} else {
Map<String, Object> params = new HashMap<String, Object>();
if (imageInfo.getFormat() == ImageFormats.TIFF) {
params.put(ImagingConstants.PARAM_KEY_COMPRESSION, TiffConstants.TIFF_COMPRESSION_LZW);
}
return Imaging.writeImageToBytes(image, imageInfo.getFormat(), params);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:27,代码来源:PdfCleanUpRenderListener.java
示例2: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final RgbeInfo info = new RgbeInfo(byteSource);
boolean canThrow = false;
try {
final ImageInfo ret = new ImageInfo(
getName(),
32, // todo may be 64 if double?
new ArrayList<String>(), ImageFormats.RGBE, getName(),
info.getHeight(), "image/vnd.radiance", 1, -1, -1, -1, -1,
info.getWidth(), false, false, false,
ImageInfo.COLOR_TYPE_RGB, "Adaptive RLE");
canThrow = true;
return ret;
} finally {
IoUtils.closeQuietly(canThrow, info);
}
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:20,代码来源:RgbeImageParser.java
示例3: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final PcxHeader pcxHeader = readPcxHeader(byteSource);
final Dimension size = getImageSize(byteSource, params);
return new ImageInfo(
"PCX",
pcxHeader.nPlanes * pcxHeader.bitsPerPixel,
new ArrayList<String>(),
ImageFormats.PCX,
"ZSoft PCX Image",
size.height,
"image/x-pcx",
1,
pcxHeader.vDpi,
Math.round(size.getHeight() / pcxHeader.vDpi),
pcxHeader.hDpi,
Math.round(size.getWidth() / pcxHeader.hDpi),
size.width,
false,
false,
!(pcxHeader.nPlanes == 3 && pcxHeader.bitsPerPixel == 8),
ImageInfo.COLOR_TYPE_RGB,
pcxHeader.encoding == PcxHeader.ENCODING_RLE ? ImageInfo.COMPRESSION_ALGORITHM_RLE
: ImageInfo.COMPRESSION_ALGORITHM_NONE);
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:27,代码来源:PcxImageParser.java
示例4: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final XpmHeader xpmHeader = readXpmHeader(byteSource);
boolean transparent = false;
int colorType = ImageInfo.COLOR_TYPE_BW;
for (final Entry<Object, PaletteEntry> entry : xpmHeader.palette
.entrySet()) {
final PaletteEntry paletteEntry = entry.getValue();
if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000) {
transparent = true;
}
if (paletteEntry.haveColor) {
colorType = ImageInfo.COLOR_TYPE_RGB;
} else if (colorType != ImageInfo.COLOR_TYPE_RGB
&& (paletteEntry.haveGray || paletteEntry.haveGray4Level)) {
colorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
}
}
return new ImageInfo("XPM version 3", xpmHeader.numCharsPerPixel * 8,
new ArrayList<String>(), ImageFormats.XPM,
"X PixMap", xpmHeader.height, "image/x-xpixmap", 1, 0, 0, 0, 0,
xpmHeader.width, false, transparent, true, colorType,
ImageInfo.COMPRESSION_ALGORITHM_NONE);
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:26,代码来源:XpmImageParser.java
示例5: write
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public void write(IIOMetadata iioMetadata, IIOImage iioImage, ImageWriteParam param)
throws IOException {
if (ios == null) {
throw new IllegalArgumentException(Messages.getString("imageio.7F"));
}
RenderedImage img = null;
if (!iioImage.hasRaster()) {
img = iioImage.getRenderedImage();
if (img instanceof BufferedImage) {
sourceRaster = ((BufferedImage) img).getRaster();
} else {
sourceRaster = img.getData();
}
} else {
sourceRaster = iioImage.getRaster();
}
Map params = new HashMap();
try {
Imaging.writeImage((BufferedImage)img,
wrapOutput(ios),//(OutputStream)ios,
ImageFormats.JPEG,
params);
} catch (ImageWriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:33,代码来源:JPEGImageWriter.java
示例6: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final PcxHeader pcxHeader = readPcxHeader(byteSource);
final Dimension size = getImageSize(byteSource, params);
return new ImageInfo(
"PCX",
pcxHeader.nPlanes * pcxHeader.bitsPerPixel,
new ArrayList<String>(),
ImageFormats.PCX,
"ZSoft PCX Image",
size.height,
"image/x-pcx",
1,
pcxHeader.vDpi,
Math.round(size.getHeight() / pcxHeader.vDpi),
pcxHeader.hDpi,
Math.round(size.getWidth() / pcxHeader.hDpi),
size.width,
false,
false,
!(pcxHeader.nPlanes == 3 && pcxHeader.bitsPerPixel == 8),
ImageInfo.ColorType.RGB,
pcxHeader.encoding == PcxHeader.ENCODING_RLE ? ImageInfo.CompressionAlgorithm.RLE
: ImageInfo.CompressionAlgorithm.NONE);
}
开发者ID:apache,项目名称:commons-imaging,代码行数:27,代码来源:PcxImageParser.java
示例7: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final XpmHeader xpmHeader = readXpmHeader(byteSource);
boolean transparent = false;
ImageInfo.ColorType colorType = ImageInfo.ColorType.BW;
for (final Entry<Object, PaletteEntry> entry : xpmHeader.palette.entrySet()) {
final PaletteEntry paletteEntry = entry.getValue();
if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000) {
transparent = true;
}
if (paletteEntry.haveColor) {
colorType = ImageInfo.ColorType.RGB;
} else if (colorType != ImageInfo.ColorType.RGB
&& (paletteEntry.haveGray || paletteEntry.haveGray4Level)) {
colorType = ImageInfo.ColorType.GRAYSCALE;
}
}
return new ImageInfo("XPM version 3", xpmHeader.numCharsPerPixel * 8,
new ArrayList<String>(), ImageFormats.XPM,
"X PixMap", xpmHeader.height, "image/x-xpixmap", 1, 0, 0, 0, 0,
xpmHeader.width, false, transparent, true, colorType,
ImageInfo.CompressionAlgorithm.NONE);
}
开发者ID:apache,项目名称:commons-imaging,代码行数:25,代码来源:XpmImageParser.java
示例8: testWriteImageRaw_happyCase
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Test
public void testWriteImageRaw_happyCase() throws ImageWriteException,
ImageReadException, IOException {
BufferedImage srcImage = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
final Map<String, Object> params = new HashMap<>();
params.put(PnmImageParser.PARAM_KEY_PNM_RAWBITS, PnmImageParser.PARAM_VALUE_PNM_RAWBITS_YES);
final byte[] dstBytes = Imaging.writeImageToBytes(srcImage, ImageFormats.PNM, params);
final BufferedImage dstImage = Imaging.getBufferedImage(dstBytes);
assertTrue(srcImage.getWidth() == dstImage.getWidth());
assertTrue(srcImage.getHeight() == dstImage.getHeight());
DataBufferInt srcData = (DataBufferInt) srcImage.getRaster().getDataBuffer();
DataBufferInt dstData = (DataBufferInt) dstImage.getRaster().getDataBuffer();
for (int bank = 0; bank < srcData.getNumBanks(); bank++) {
int[] actual = srcData.getData(bank);
int[] expected = dstData.getData(bank);
assertArrayEquals(actual, expected);
}
}
开发者ID:apache,项目名称:commons-imaging,代码行数:24,代码来源:PnmImageParserTest.java
示例9: imageWriteExample
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
public static byte[] imageWriteExample(final File file)
throws ImageReadException, ImageWriteException, IOException {
// read image
final BufferedImage image = Imaging.getBufferedImage(file);
final ImageFormat format = ImageFormats.TIFF;
final Map<String, Object> params = new HashMap<>();
// set optional parameters if you like
params.put(ImagingConstants.PARAM_KEY_COMPRESSION, Integer.valueOf(
TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED));
final byte[] bytes = Imaging.writeImageToBytes(image, format, params);
return bytes;
}
开发者ID:apache,项目名称:commons-imaging,代码行数:17,代码来源:ImageWriteExample.java
示例10: toPNG
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
public void toPNG(String resolution, String destination, boolean appendResolution) {
ImageTransformEntry imageTransformEntry = new ImageTransformEntry();
imageTransformEntry.resolution = resolution;
imageTransformEntry.destination = destination;
imageTransformEntry.source = sourcePath;
imageTransformEntry.appendResolution = appendResolution;
imageTransformEntry.format = ImageFormats.PNG;
transformEntries.add(imageTransformEntry);
}
开发者ID:FibreFoX,项目名称:imagetransform-gradle-plugin,代码行数:12,代码来源:ImageFormatRequest.java
示例11: toICO
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
public void toICO(String resolution, String destination, boolean appendResolution) {
ImageTransformEntry imageTransformEntry = new ImageTransformEntry();
imageTransformEntry.resolution = resolution;
imageTransformEntry.destination = destination;
imageTransformEntry.source = sourcePath;
imageTransformEntry.appendResolution = appendResolution;
imageTransformEntry.format = ImageFormats.ICO;
transformEntries.add(imageTransformEntry);
}
开发者ID:FibreFoX,项目名称:imagetransform-gradle-plugin,代码行数:12,代码来源:ImageFormatRequest.java
示例12: toBMP
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
public void toBMP(String resolution, String destination, boolean appendResolution) {
ImageTransformEntry imageTransformEntry = new ImageTransformEntry();
imageTransformEntry.resolution = resolution;
imageTransformEntry.destination = destination;
imageTransformEntry.source = sourcePath;
imageTransformEntry.appendResolution = appendResolution;
imageTransformEntry.format = ImageFormats.BMP;
transformEntries.add(imageTransformEntry);
}
开发者ID:FibreFoX,项目名称:imagetransform-gradle-plugin,代码行数:12,代码来源:ImageFormatRequest.java
示例13: toICNS
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
public void toICNS(String resolution, String destination, boolean appendResolution) {
ImageTransformEntry imageTransformEntry = new ImageTransformEntry();
imageTransformEntry.resolution = resolution;
imageTransformEntry.destination = destination;
imageTransformEntry.source = sourcePath;
imageTransformEntry.appendResolution = appendResolution;
imageTransformEntry.format = ImageFormats.ICNS;
transformEntries.add(imageTransformEntry);
}
开发者ID:FibreFoX,项目名称:imagetransform-gradle-plugin,代码行数:12,代码来源:ImageFormatRequest.java
示例14: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final XbmHeader xbmHeader = readXbmHeader(byteSource);
return new ImageInfo("XBM", 1, new ArrayList<String>(),
ImageFormats.XBM, "X BitMap", xbmHeader.height,
"image/x-xbitmap", 1, 0, 0, 0, 0, xbmHeader.width, false,
false, false, ImageInfo.COLOR_TYPE_BW,
ImageInfo.COMPRESSION_ALGORITHM_NONE);
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:11,代码来源:XbmImageParser.java
示例15: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, Map<String, Object> params)
throws ImageReadException, IOException {
// make copy of params; we'll clear keys as we consume them.
params = (params == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(params);
if (params.containsKey(PARAM_KEY_VERBOSE)) {
params.remove(PARAM_KEY_VERBOSE);
}
if (!params.isEmpty()) {
final Object firstKey = params.keySet().iterator().next();
throw new ImageReadException("Unknown parameter: " + firstKey);
}
final IcnsContents contents = readImage(byteSource);
final List<BufferedImage> images = IcnsDecoder
.decodeAllImages(contents.icnsElements);
if (images.isEmpty()) {
throw new ImageReadException("No icons in ICNS file");
}
final BufferedImage image0 = images.get(0);
return new ImageInfo("Icns", 32, new ArrayList<String>(),
ImageFormats.ICNS, "ICNS Apple Icon Image",
image0.getHeight(), "image/x-icns", images.size(), 0, 0, 0, 0,
image0.getWidth(), false, true, false,
ImageInfo.COLOR_TYPE_RGB,
ImageInfo.COMPRESSION_ALGORITHM_UNKNOWN);
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:30,代码来源:IcnsImageParser.java
示例16: getImageInfo
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final WbmpHeader wbmpHeader = readWbmpHeader(byteSource);
return new ImageInfo("WBMP", 1, new ArrayList<String>(),
ImageFormats.WBMP,
"Wireless Application Protocol Bitmap", wbmpHeader.height,
"image/vnd.wap.wbmp", 1, 0, 0, 0, 0, wbmpHeader.width, false,
false, false, ImageInfo.COLOR_TYPE_BW,
ImageInfo.COMPRESSION_ALGORITHM_NONE);
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:12,代码来源:WbmpImageParser.java
示例17: readIconData
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
private IconData readIconData(final byte[] iconData, final IconInfo fIconInfo)
throws ImageReadException, IOException {
final ImageFormat imageFormat = Imaging.guessFormat(iconData);
if (imageFormat.equals(ImageFormats.PNG)) {
final BufferedImage bufferedImage = Imaging.getBufferedImage(iconData);
return new PNGIconData(fIconInfo, bufferedImage);
}
return readBitmapIconData(iconData, fIconInfo);
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:10,代码来源:IcoImageParser.java
示例18: getAcceptedTypes
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
protected ImageFormat[] getAcceptedTypes() {
return new ImageFormat[] {
ImageFormats.PBM,
ImageFormats.PGM,
ImageFormats.PPM,
ImageFormats.PNM,
ImageFormats.PAM
};
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:11,代码来源:PnmImageParser.java
示例19: write
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
@Override
public void write(IIOMetadata streamMetadata, IIOImage iioimage, ImageWriteParam param) throws IOException {
if (output == null) {
throw new IllegalStateException(Messages.getString("imageio.81"));
}
if (iioimage == null) {
throw new IllegalArgumentException(Messages.getString("imageio.82"));
}
if (iioimage.hasRaster() && !canWriteRasters()) {
throw new UnsupportedOperationException(Messages.getString("imageio.83"));
}// ImageOutputStreamImpl
RenderedImage image = iioimage.getRenderedImage();
try {
Map params = new HashMap();
Imaging.writeImage((BufferedImage) image,
wrapOutput(getOutput()),
ImageFormats.PNG,
params);
}
catch (ImageWriteException e) {
e.printStackTrace();
}
}
开发者ID:windwardadmin,项目名称:android-awt,代码行数:27,代码来源:PNGImageWriter.java
示例20: getImageFormat
import org.apache.commons.imaging.ImageFormats; //导入依赖的package包/类
private ImageFormat getImageFormat(String formatName) {
if ("jpg".equalsIgnoreCase(formatName)) {
return ImageFormats.JPEG;
} else if ("jpeg".equalsIgnoreCase(formatName)) {
return ImageFormats.JPEG;
} else if ("png".equalsIgnoreCase(formatName)) {
return ImageFormats.PNG;
} else {
throw new IllegalArgumentException("Don't know how to handle : " + formatName);
}
}
开发者ID:sgoeschl,项目名称:java-image-processing-survival-guide,代码行数:13,代码来源:BaseSanselanTest.java
注:本文中的org.apache.commons.imaging.ImageFormats类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论