本文整理汇总了Java中org.apache.sanselan.common.byteSources.ByteSource类的典型用法代码示例。如果您正苦于以下问题:Java ByteSource类的具体用法?Java ByteSource怎么用?Java ByteSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteSource类属于org.apache.sanselan.common.byteSources包,在下文中一共展示了ByteSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateExifMetadataLossy
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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);
}
示例2: getImageSize
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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};
}
示例3: readTiffHeader
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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);
}
}
}
示例4: getXmpXml
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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.");
}
}
示例5: collectRawImageData
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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;
}
示例6: fillInValue
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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);
}
示例7: checkAdobeMarker
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
/**
* Check Adobe markers in File
* @param file
* @throws IOException
* @throws ImageReadException
*/
public void checkAdobeMarker(File file) throws IOException, ImageReadException {
JpegImageParser parser = new JpegImageParser();
ByteSource byteSource = new ByteSourceFile(file);
@SuppressWarnings("rawtypes")
ArrayList segments = parser.readSegments(byteSource, new int[] { 0xffee }, true);
if (segments != null && segments.size() >= 1) {
UnknownSegment app14Segment = (UnknownSegment) segments.get(0);
byte[] data = app14Segment.bytes;
if (data.length >= 12 && data[0] == 'A' && data[1] == 'd' && data[2] == 'o' && data[3] == 'b' && data[4] == 'e')
{
hasAdobeMarker = true;
int transform = app14Segment.bytes[11] & 0xff;
if (transform == 2)
colorType = COLOR_TYPE_YCCK;
}
}
}
示例8: checkAdobeMarker
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
public static void checkAdobeMarker(File file) throws IOException, ImageReadException {
JpegImageParser parser = new JpegImageParser();
ByteSource byteSource = new ByteSourceFile(file);
@SuppressWarnings("rawtypes")
ArrayList segments = parser.readSegments(byteSource, new int[] { 0xffee }, true);
if (segments != null && segments.size() >= 1) {
UnknownSegment app14Segment = (UnknownSegment) segments.get(0);
byte[] data = app14Segment.bytes;
if (data.length >= 12 && data[0] == 'A' && data[1] == 'd' && data[2] == 'o' && data[3] == 'b' && data[4] == 'e')
{
hasAdobeMarker = true;
int transform = app14Segment.bytes[11] & 0xff;
if (transform == 2)
colorType = COLOR_TYPE_YCCK;
}
}
}
示例9: checkAdobeMarker
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
private void checkAdobeMarker(File file) throws IOException, ImageReadException {
JpegImageParser parser = new JpegImageParser();
ByteSource byteSource = new ByteSourceFile(file);
@SuppressWarnings("rawtypes")
List segments = parser.readSegments(byteSource, new int[]{0xffee}, true);
if (segments != null && !segments.isEmpty()) {
UnknownSegment app14Segment = (UnknownSegment) segments.get(0);
byte[] data = app14Segment.bytes;
if (data.length >= 12 && data[0] == 'A' && data[1] == 'd' && data[2] == 'o' && data[3] == 'b' && data[4] == 'e') {
hasAdobeMarker = Boolean.TRUE;
int transform = app14Segment.bytes[11] & 0xff;
if (transform == 2) {
colorType = COLOR_TYPE_YCCK;
}
}
}
}
示例10: getImageSize
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
public Dimension getImageSize(ByteSource byteSource,
Map params)
throws ImageReadException, IOException
{
// make copy of params; we'll clear keys as we consume them.
params = (params == null) ? new HashMap() : new HashMap(params);
boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
false);
if (params.containsKey(PARAM_KEY_VERBOSE))
params.remove(PARAM_KEY_VERBOSE);
if (params.size() > 0)
{
Object firstKey = params.keySet().iterator().next();
throw new ImageReadException("Unknown parameter: " + firstKey);
}
IcnsContents contents = readImage(byteSource);
ArrayList images = IcnsDecoder.decodeAllImages(contents.icnsElements);
if (images.isEmpty())
throw new ImageReadException("No icons in ICNS file");
BufferedImage image0 = (BufferedImage) images.get(0);
return new Dimension(image0.getWidth(), image0.getHeight());
}
示例11: getICCProfileBytes
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
throws ImageReadException, IOException
{
ArrayList chunks = readChunks(byteSource, new int[] { iCCP, }, true);
if ((chunks == null) || (chunks.size() < 1))
{
// throw new ImageReadException("Png: No chunks");
return null;
}
if (chunks.size() > 1)
throw new ImageReadException(
"PNG contains more than one ICC Profile ");
PNGChunkiCCP pngChunkiCCP = (PNGChunkiCCP) chunks.get(0);
byte bytes[] = pngChunkiCCP.UncompressedProfile;
return (bytes);
}
示例12: getImageSize
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
public Dimension 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 Dimension(fSOFNSegment.width, fSOFNSegment.height);
}
示例13: readBmpHeaderInfo
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
private BmpHeaderInfo readBmpHeaderInfo(ByteSource byteSource,
boolean verbose) throws ImageReadException, IOException
{
InputStream is = null;
try
{
is = byteSource.getInputStream();
// readSignature(is);
return readBmpHeaderInfo(is, null, verbose);
} finally
{
try
{
if (is != null) {
is.close();
}
} catch (Exception e)
{
Debug.debug(e);
}
}
}
示例14: getXmpXml
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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.");
}
}
示例15: fillInValue
import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的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);
}