本文整理汇总了Java中org.apache.sanselan.ImageWriteException类的典型用法代码示例。如果您正苦于以下问题:Java ImageWriteException类的具体用法?Java ImageWriteException怎么用?Java ImageWriteException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageWriteException类属于org.apache.sanselan包,在下文中一共展示了ImageWriteException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateExifMetadataLossy
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
/**
* Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.
* <p>
* Note that this uses the "Lossy" approach - the algorithm overwrites the entire EXIF segment,
* ignoring the possibility that it may be discarding data it couldn't parse (such as Maker Notes).
* <p>
* @param byteSource ByteSource containing Jpeg image data.
* @param os OutputStream to write the image to.
* @param outputSet TiffOutputSet containing the EXIF data to write.
*/
public void updateExifMetadataLossy(ByteSource byteSource, OutputStream os,
TiffOutputSet outputSet) throws ImageReadException, IOException,
ImageWriteException
{
JFIFPieces jfifPieces = analyzeJFIF(byteSource);
List pieces = jfifPieces.pieces;
TiffImageWriterBase writer = new TiffImageWriterLossy(
outputSet.byteOrder);
boolean includeEXIFPrefix = true;
byte newBytes[] = writeExifSegment(writer, outputSet, includeEXIFPrefix);
writeSegmentsReplacingExif(os, pieces, newBytes);
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:26,代码来源:ExifRewriter.java
示例2: writeExifSegment
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
private byte[] writeExifSegment(TiffImageWriterBase writer,
TiffOutputSet outputSet, boolean includeEXIFPrefix)
throws IOException, ImageWriteException
{
ByteArrayOutputStream os = new ByteArrayOutputStream();
if (includeEXIFPrefix)
{
os.write(EXIF_IDENTIFIER_CODE);
os.write(0);
os.write(0);
}
writer.write(os, outputSet);
return os.toByteArray();
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:18,代码来源:ExifRewriter.java
示例3: getOutputSet
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
public TiffOutputSet getOutputSet() throws ImageWriteException
{
int byteOrder = contents.header.byteOrder;
TiffOutputSet result = new TiffOutputSet(byteOrder);
ArrayList srcDirs = getDirectories();
for (int i = 0; i < srcDirs.size(); i++)
{
TiffImageMetadata.Directory srcDir = (TiffImageMetadata.Directory) srcDirs
.get(i);
if (null != result.findDirectory(srcDir.type))
{
// Certain cameras right directories more than once.
// This is a bug.
// Ignore second directory of a given type.
continue;
}
TiffOutputDirectory outputDirectory = srcDir
.getOutputDirectory(byteOrder);
result.addDirectory(outputDirectory);
}
return result;
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:27,代码来源:TiffImageMetadata.java
示例4: writeData
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
public byte[] writeData(Object o, int byteOrder) throws ImageWriteException
{
final byte[] originalArray;
if (o instanceof byte[]) {
originalArray = (byte[])o;
}
else if (o instanceof String) {
originalArray = ((String)o).getBytes();
}
else
throw new ImageWriteException("Unknown data type: " + o);
final byte[] retVal = new byte[originalArray.length+1]; // make sure '\0' char is added.
System.arraycopy(originalArray, 0, retVal, 0, originalArray.length);
return retVal;
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:17,代码来源:FieldTypeASCII.java
示例5: updateOffsetsStep
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
private void updateOffsetsStep(List outputItems) throws IOException,
ImageWriteException
{
int offset = TIFF_HEADER_SIZE;
for (int i = 0; i < outputItems.size(); i++)
{
TiffOutputItem outputItem = (TiffOutputItem) outputItems.get(i);
outputItem.setOffset(offset);
int itemLength = outputItem.getItemLength();
offset += itemLength;
int remainder = imageDataPaddingLength(itemLength);
offset += remainder;
}
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:18,代码来源:TiffImageWriterLossy.java
示例6: writeStep
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
private void writeStep(BinaryOutputStream bos, List outputItems)
throws IOException, ImageWriteException
{
writeImageFileHeader(bos);
for (int i = 0; i < outputItems.size(); i++)
{
TiffOutputItem outputItem = (TiffOutputItem) outputItems.get(i);
outputItem.writeItem(bos);
int length = outputItem.getItemLength();
int remainder = imageDataPaddingLength(length);
for (int j = 0; j < remainder; j++)
bos.write(0);
}
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:20,代码来源:TiffImageWriterLossy.java
示例7: create
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
public static TiffOutputField create(TagInfo tagInfo, int byteOrder,
String value) throws ImageWriteException
{
FieldType fieldType;
if (tagInfo.dataTypes == null)
fieldType = FIELD_TYPE_ASCII;
else if (tagInfo.dataTypes == FIELD_TYPE_DESCRIPTION_ASCII)
fieldType = FIELD_TYPE_ASCII;
else if (tagInfo.dataTypes[0] == FIELD_TYPE_ASCII)
fieldType = FIELD_TYPE_ASCII;
else
throw new ImageWriteException("Tag has unexpected data type.");
byte bytes[] = fieldType.writeData(value, byteOrder);
return new TiffOutputField(tagInfo.tag, tagInfo, fieldType, bytes.length, bytes);
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:18,代码来源:TiffOutputField.java
示例8: setData
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
protected void setData(byte bytes[]) throws ImageWriteException
{
// if(tagInfo.isUnknown())
// Debug.debug("unknown tag(0x" + Integer.toHexString(tag)
// + ") setData", bytes);
if (this.bytes.length != bytes.length)
throw new ImageWriteException("Cannot change size of value.");
// boolean wasLocalValue = isLocalValue();
this.bytes = bytes;
if (separateValueItem != null)
separateValueItem.updateValue(bytes);
// if (isLocalValue() != wasLocalValue)
// throw new Error("Bug. Locality disrupted! "
// + tagInfo.getDescription());
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:18,代码来源:TiffOutputField.java
示例9: convertIntArrayToRationalArray
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
protected final byte[] convertIntArrayToRationalArray(int numerators[],
int denominators[], int byteOrder) throws ImageWriteException
{
if (numerators.length != denominators.length)
throw new ImageWriteException("numerators.length ("
+ numerators.length + " != denominators.length ("
+ denominators.length + ")");
byte result[] = new byte[numerators.length * 8];
for (int i = 0; i < numerators.length; i++)
{
writeIntInToByteArray(numerators[i], result, i * 8, byteOrder);
writeIntInToByteArray(denominators[i], result, i * 8 + 4, byteOrder);
}
return result;
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:19,代码来源:BinaryFileFunctions.java
示例10: convertRationalArrayToByteArray
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
protected final byte[] convertRationalArrayToByteArray(
RationalNumber numbers[], int byteOrder) throws ImageWriteException
{
// Debug.debug("convertRationalArrayToByteArray 2");
byte result[] = new byte[numbers.length * 8];
for (int i = 0; i < numbers.length; i++)
{
writeIntInToByteArray(numbers[i].numerator, result, i * 8,
byteOrder);
writeIntInToByteArray(numbers[i].divisor, result, i * 8 + 4,
byteOrder);
}
return result;
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:17,代码来源:BinaryFileFunctions.java
示例11: write4ByteInteger
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
public final void write4ByteInteger(int value) throws ImageWriteException,
IOException
{
if (byteOrder == BYTE_ORDER_MOTOROLA)
{
write(0xff & (value >> 24));
write(0xff & (value >> 16));
write(0xff & (value >> 8));
write(0xff & value);
} else
{
write(0xff & value);
write(0xff & (value >> 8));
write(0xff & (value >> 16));
write(0xff & (value >> 24));
}
}
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:18,代码来源:BinaryOutputStream.java
示例12: removeExifMetadata
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
public static void removeExifMetadata(final File jpegImageFile,
final File dst) throws IOException, ImageReadException,
ImageWriteException {
OutputStream os = null;
try {
os = new FileOutputStream(dst);
os = new BufferedOutputStream(os);
new ExifRewriter().removeExifMetadata(jpegImageFile, os);
} finally {
if (os != null) {
try {
os.close();
} catch (final IOException e) {
}
}
}
}
开发者ID:shaolinwu,项目名称:uimaster,代码行数:18,代码来源:ImageUtil.java
示例13: updateExifMetadataLossy
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
/**
* Reads a Jpeg image, replaces the EXIF metadata and writes the result to a stream.
* <p>
* Note that this uses the "Lossy" approach - the algorithm overwrites the entire EXIF segment,
* ignoring the possibility that it may be discarding data it couldn't parse (such as Maker Notes).
* <p>
* @param byteSource ByteSource containing Jpeg image data.
* @param os OutputStream to write the image to.
* @param outputSet TiffOutputSet containing the EXIF data to write.
*/
public void updateExifMetadataLossy(ByteSource byteSource, OutputStream os,
TiffOutputSet outputSet) throws ImageReadException, IOException,
ImageWriteException
{
JFIFPieces jfifPieces = analyzeJFIF(byteSource);
List pieces = jfifPieces.pieces;
TiffImageWriterBase writer = new TiffImageWriterLossy(
outputSet.byteOrder);
boolean includeEXIFPrefix = true;
byte newBytes[] = writeExifSegment(writer, outputSet, includeEXIFPrefix);
writeSegmentsReplacingExif(os, pieces, newBytes);
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:26,代码来源:ExifRewriter.java
示例14: writeSegments
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
protected void writeSegments(OutputStream os, List segments)
throws ImageWriteException, IOException
{
try
{
os.write(SOI);
for (int i = 0; i < segments.size(); i++)
{
JFIFPiece piece = (JFIFPiece) segments.get(i);
piece.write(os);
}
os.close();
os = null;
} finally
{
try
{
if (os != null)
os.close();
} catch (Exception e)
{
// swallow exception; already in the context of an exception.
}
}
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:27,代码来源:JpegRewriter.java
示例15: readIconData
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
private IconData readIconData(byte[] iconData, IconInfo fIconInfo)
throws ImageReadException, IOException
{
ImageFormat imageFormat = Sanselan.guessFormat(iconData);
if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_PNG))
{
BufferedImage bufferedImage = Sanselan.getBufferedImage(iconData);
PNGIconData pngIconData = new PNGIconData(fIconInfo, bufferedImage);
return pngIconData;
}
else
{
try
{
return readBitmapIconData(iconData, fIconInfo);
}
catch (ImageWriteException imageWriteException)
{
IOException ioe = new IOException();
ioe.initCause(imageWriteException);
throw ioe;
}
}
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:25,代码来源:IcoImageParser.java
示例16: getOutputSet
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
public TiffOutputSet getOutputSet() throws ImageWriteException
{
int byteOrder = contents.header.byteOrder;
TiffOutputSet result = new TiffOutputSet(byteOrder);
ArrayList srcDirs = getDirectories();
for (int i = 0; i < srcDirs.size(); i++)
{
TiffImageMetadata.Directory srcDir = (TiffImageMetadata.Directory) srcDirs
.get(i);
if (null != result.findDirectory(srcDir.type))
{
// Certain cameras right directories more than once.
// This is a bug.
// Ignore second directory of a given type.
continue;
}
TiffOutputDirectory outputDirectory = srcDir
.getOutputDirectory(byteOrder);
result.addDirectory(outputDirectory);
}
return result;
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:27,代码来源:TiffImageMetadata.java
示例17: writeStep
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
private void writeStep(BinaryOutputStream bos, List outputItems)
throws IOException, ImageWriteException
{
writeImageFileHeader(bos);
for (int i = 0; i < outputItems.size(); i++)
{
TiffOutputItem outputItem = (TiffOutputItem) outputItems.get(i);
outputItem.writeItem(bos);
int length = outputItem.getItemLength();
int remainder = imageDataPaddingLength(length);
for (int j = 0; j < remainder; j++)
bos.write(0);
}
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:20,代码来源:TiffImageWriterLossy.java
示例18: setData
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
protected void setData(byte bytes[]) throws ImageWriteException
{
// if(tagInfo.isUnknown())
// Debug.debug("unknown tag(0x" + Integer.toHexString(tag)
// + ") setData", bytes);
if (this.bytes.length != bytes.length)
throw new ImageWriteException("Cannot change size of value.");
// boolean wasLocalValue = isLocalValue();
this.bytes = bytes;
if (separateValueItem != null)
separateValueItem.updateValue(bytes);
// if (isLocalValue() != wasLocalValue)
// throw new Error("Bug. Locality disrupted! "
// + tagInfo.getDescription());
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:18,代码来源:TiffOutputField.java
示例19: writeChunkzTXt
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
private void writeChunkzTXt(OutputStream os, PngText.zTXt text)
throws IOException, ImageWriteException
{
if (!UnicodeUtils.isValidISO_8859_1(text.keyword))
throw new ImageWriteException(
"Png zTXt chunk keyword is not ISO-8859-1: " + text.keyword);
if (!UnicodeUtils.isValidISO_8859_1(text.text))
throw new ImageWriteException(
"Png zTXt chunk text is not ISO-8859-1: " + text.text);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// keyword
baos.write(text.keyword.getBytes("ISO-8859-1"));
baos.write(0);
// compression method
baos.write(PngConstants.COMPRESSION_DEFLATE_INFLATE);
// text
baos
.write(new ZLibUtils().deflate(text.text
.getBytes("ISO-8859-1")));
writeChunk(os, zTXt_CHUNK_TYPE, baos.toByteArray());
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:27,代码来源:PngWriter.java
示例20: groupColors
import org.apache.sanselan.ImageWriteException; //导入依赖的package包/类
public Map groupColors(BufferedImage image, int max_colors)
throws ImageWriteException
{
int max = Integer.MAX_VALUE;
for (int i = 0; i < 8; i++)
{
int mask = 0xff & (0xff << i);
mask = mask | (mask << 8) | (mask << 16) | (mask << 24);
Debug.debug("mask(" + i + ")", mask + " ("
+ Integer.toHexString(mask) + ")");
Map result = groupColors1(image, max, mask);
if (result != null)
return result;
}
throw new Error("");
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:20,代码来源:MedianCutQuantizer.java
注:本文中的org.apache.sanselan.ImageWriteException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论