当前位置: 首页>>代码示例>>Java>>正文


Java ImageReadException类代码示例

本文整理汇总了Java中org.apache.sanselan.ImageReadException的典型用法代码示例。如果您正苦于以下问题:Java ImageReadException类的具体用法?Java ImageReadException怎么用?Java ImageReadException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ImageReadException类属于org.apache.sanselan包,在下文中一共展示了ImageReadException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read4ByteInteger

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public final int read4ByteInteger(String exception)
		throws ImageReadException, IOException
{
	int byte0 = is.read();
	int byte1 = is.read();
	int byte2 = is.read();
	int byte3 = is.read();
	if (byte0 < 0 || byte1 < 0 || byte2 < 0 || byte3 < 0)
		throw new ImageReadException(exception);

	if (byteOrder == BYTE_ORDER_MOTOROLA) // motorola, big endian
		return ((0xff & byte0) << 24) + ((0xff & byte1) << 16)
				+ ((0xff & byte2) << 8) + ((0xff & byte3) << 0);
	else
		// intel, little endian
		return ((0xff & byte3) << 24) + ((0xff & byte2) << 16)
				+ ((0xff & byte1) << 8) + ((0xff & byte0) << 0);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:19,代码来源:BinaryInputStream.java

示例2: updateExifMetadataLossy

import org.apache.sanselan.ImageReadException; //导入依赖的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

示例3: canDecodeInput

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public boolean canDecodeInput(Object input) throws IOException {
  if (!(input instanceof ImageInputStream)) {
    return false;
  }
  final ImageInputStream stream = (ImageInputStream)input;
  try {
    final ImageFormat imageFormat = Sanselan.guessFormat(new MyByteSource(stream));
    if (myFormats.contains(imageFormat)) {
      myFormat.set(imageFormat);
      return true;
    }
    return false;
  }
  catch (ImageReadException e) {
    throw new IOException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SanselanImageReaderSpi.java

示例4: getImageSize

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public int[] getImageSize(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	ArrayList segments = readSegments(byteSource, new int[] {
			// kJFIFMarker,
			SOF0Marker,

			SOF1Marker, SOF2Marker, SOF3Marker, SOF5Marker, SOF6Marker,
			SOF7Marker, SOF9Marker, SOF10Marker, SOF11Marker, SOF13Marker,
			SOF14Marker, SOF15Marker,

	}, true);

	if ((segments == null) || (segments.size() < 1))
		throw new ImageReadException("No JFIF Data Found.");

	if (segments.size() > 1)
		throw new ImageReadException("Redundant JFIF Data Found.");

	SOFNSegment fSOFNSegment = (SOFNSegment) segments.get(0);

	return new int[]{fSOFNSegment.width, fSOFNSegment.height};
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:24,代码来源:JpegImageParser.java

示例5: readByteArray

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public final byte[] readByteArray(String name, int length, String exception)
		throws ImageReadException, IOException
{
	byte result[] = new byte[length];

	int read = 0;
	while (read < length)
	{
		int count = is.read(result, read, length - read);
		if (count < 1)
			throw new IOException(exception);

		read += count;
	}

	if (debug)
	{
		for (int i = 0; ((i < length) && (i < 150)); i++)
		{
			debugNumber(name + " (" + i + ")", 0xff & result[i]);
		}
	}
	return result;
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:25,代码来源:BinaryInputStream.java

示例6: findField

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public TiffField findField(TagInfo tag, boolean failIfMissing)
		throws ImageReadException
{
	if (entries == null)
		return null;

	for (int i = 0; i < entries.size(); i++)
	{
		TiffField field = (TiffField) entries.get(i);
		if (field.tag == tag.tag)
			return field;
	}

	if (failIfMissing)
		throw new ImageReadException("Missing expected field: "
				+ tag.getDescription());

	return null;
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:20,代码来源:TiffDirectory.java

示例7: readAndVerifyBytes

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public final void readAndVerifyBytes(byte expected[], String exception)
		throws ImageReadException, IOException
{
	for (int i = 0; i < expected.length; i++)
	{
		int data = is.read();
		byte b = (byte) (0xff & data);

		if ((data < 0) || (b != expected[i]))
		{
			System.out.println("i" + ": " + i);

			this.debugByteArray("expected", expected);
			debugNumber("data[" + i + "]", b);
			// debugNumber("expected[" + i + "]", expected[i]);

			throw new ImageReadException(exception);
		}
	}
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:21,代码来源:BinaryInputStream.java

示例8: getJpegRawImageDataElement

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public ImageDataElement getJpegRawImageDataElement()
		throws ImageReadException
{
	TiffField jpegInterchangeFormat = findField(TIFF_TAG_JPEG_INTERCHANGE_FORMAT);
	TiffField jpegInterchangeFormatLength = findField(TIFF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH);

	if ((jpegInterchangeFormat != null)
			&& (jpegInterchangeFormatLength != null))
	{
		int offset = jpegInterchangeFormat.getIntArrayValue()[0];
		int byteCount = jpegInterchangeFormatLength.getIntArrayValue()[0];

		return new ImageDataElement(offset, byteCount);
	}
	else
		throw new ImageReadException("Couldn't find image data.");
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:18,代码来源:TiffDirectory.java

示例9: readTiffHeader

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
private TiffHeader readTiffHeader(ByteSource byteSource,
		FormatCompliance formatCompliance) throws ImageReadException,
		IOException
{
	InputStream is = null;
	try
	{
		is = byteSource.getInputStream();
		return readTiffHeader(is, formatCompliance);
	} finally
	{
		try
		{
			if (is != null)
				is.close();
		} catch (Exception e)
		{
			Debug.debug(e);
		}
	}
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:22,代码来源:TiffReader.java

示例10: read2Bytes

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
protected final int read2Bytes(String name, InputStream is,
		String exception, int byteOrder) throws ImageReadException,
		IOException
{
	int size = 2;
	byte bytes[] = new byte[size];

	int read = 0;
	while (read < size)
	{
		int count = is.read(bytes, read, size - read);
		if (count < 1)
			throw new IOException(exception);

		read += count;
	}

	return convertByteArrayToShort(name, bytes, byteOrder);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:20,代码来源:BinaryFileFunctions.java

示例11: getXmpXml

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public String getXmpXml(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	FormatCompliance formatCompliance = FormatCompliance.getDefault();
	TiffContents contents = new TiffReader(isStrict(params))
			.readDirectories(byteSource, false, formatCompliance);
	TiffDirectory directory = (TiffDirectory) contents.directories.get(0);

	TiffField xmpField = directory.findField(TIFF_TAG_XMP, false);
	if (xmpField == null)
		return null;

	byte bytes[] = xmpField.getByteArrayValue();

	try
	{
		// segment data is UTF-8 encoded xml.
		String xml = new String(bytes, "utf-8");
		return xml;
	} catch (UnsupportedEncodingException e)
	{
		throw new ImageReadException("Invalid JPEG XMP Segment.");
	}
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:25,代码来源:TiffImageParser.java

示例12: collectRawImageData

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public List collectRawImageData(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	FormatCompliance formatCompliance = FormatCompliance.getDefault();
	TiffContents contents = new TiffReader(isStrict(params))
			.readDirectories(byteSource, true, formatCompliance);

	List result = new ArrayList();
	for (int i = 0; i < contents.directories.size(); i++)
	{
		TiffDirectory directory = (TiffDirectory) contents.directories
				.get(i);
		List dataElements = directory.getTiffRawImageDataElements();
		for (int j = 0; j < dataElements.size(); j++)
		{
			TiffDirectory.ImageDataElement element = (TiffDirectory.ImageDataElement) dataElements
					.get(j);
			byte bytes[] = byteSource.getBlock(element.offset,
					element.length);
			result.add(bytes);
		}
	}
	return result;
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:25,代码来源:TiffImageParser.java

示例13: read3Bytes

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
protected final int read3Bytes(String name, String exception, int byteOrder)
		throws ImageReadException, IOException
{
	int size = 3;
	byte bytes[] = new byte[size];

	int read = 0;
	while (read < size)
	{
		int count = is.read(bytes, read, size - read);
		if (count < 1)
			throw new IOException(exception);

		read += count;
	}

	return convertByteArrayToInt(name, bytes, 0, 3, byteOrder);

}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:20,代码来源:BinaryInputStream.java

示例14: fillInValue

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public void fillInValue(ByteSource byteSource) throws ImageReadException,
		IOException
{
	if (fieldType.isLocalValue(this))
		return;

	int valueLength = getValueLengthInBytes();

	// Debug.debug("fillInValue tag", tag);
	// Debug.debug("fillInValue tagInfo", tagInfo);
	// Debug.debug("fillInValue valueOffset", valueOffset);
	// Debug.debug("fillInValue valueLength", valueLength);

	byte bytes[] = byteSource.getBlock(valueOffset, valueLength);
	setOversizeValue(bytes);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:17,代码来源:TiffField.java

示例15: readAndVerifyBytes

import org.apache.sanselan.ImageReadException; //导入依赖的package包/类
public final void readAndVerifyBytes(InputStream is, byte expected[],
		String exception) throws ImageReadException, IOException
{
	for (int i = 0; i < expected.length; i++)
	{
		int data = is.read();
		byte b = (byte) (0xff & data);

		if (data < 0)
			throw new ImageReadException("Unexpected EOF.");

		if (b != expected[i])
		{
			// System.out.println("i" + ": " + i);

			// this.debugByteArray("expected", expected);
			// debugNumber("data[" + i + "]", b);
			// debugNumber("expected[" + i + "]", expected[i]);

			throw new ImageReadException(exception);
		}
	}
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:24,代码来源:BinaryFileFunctions.java


注:本文中的org.apache.sanselan.ImageReadException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。