• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ByteSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ByteSource类属于org.apache.sanselan.common.byteSources包,在下文中一共展示了ByteSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:26,代码来源:ExifRewriter.java


示例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};
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:24,代码来源:JpegImageParser.java


示例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);
		}
	}
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:22,代码来源:TiffReader.java


示例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.");
	}
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:25,代码来源:TiffImageParser.java


示例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;
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:25,代码来源:TiffImageParser.java


示例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);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:17,代码来源:TiffField.java


示例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;
        }
    }
}
 
开发者ID:nkiraly,项目名称:Java-FPDF,代码行数:24,代码来源:JpegReader.java


示例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;
        }
    }
}
 
开发者ID:lklong,项目名称:imageweb,代码行数:18,代码来源:CmykImageUtil.java


示例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;
            }
        }
    }
}
 
开发者ID:YAMJ,项目名称:yamj-v2,代码行数:18,代码来源:JpegReader.java


示例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());
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:27,代码来源:IcnsImageParser.java


示例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);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:21,代码来源:PngImageParser.java


示例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);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:24,代码来源:JpegImageParser.java


示例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);
        }

    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:25,代码来源:BmpImageParser.java


示例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.");
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:25,代码来源:TiffImageParser.java


示例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);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:17,代码来源:TiffField.java


示例16: readHeader

import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
private FileInfo readHeader(ByteSource byteSource)
        throws ImageReadException, IOException
{
    InputStream is = null;

    try
    {
        is = byteSource.getInputStream();

        return readHeader(is);
    } finally
    {
        try
        {
            if (is != null) {
                is.close();
            }
        } catch (Exception e)
        {
            Debug.debug(e);
        }
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:24,代码来源:PNMImageParser.java


示例17: readHeader

import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
private PSDHeaderInfo readHeader(ByteSource byteSource)
        throws ImageReadException, IOException
{
    InputStream is = null;

    try
    {
        is = byteSource.getInputStream();

        return readHeader(is);
    } finally
    {
        try
        {
            if (is != null) {
                is.close();
            }
        } catch (Exception e)
        {
            Debug.debug(e);
        }

    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:25,代码来源:PsdImageParser.java


示例18: getICCProfile

import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
protected static ICC_Profile getICCProfile(ByteSource byteSource, Map params)
        throws ImageReadException, IOException {
    byte bytes[] = getICCProfileBytes(byteSource, params);
    if (bytes == null)
        return null;

    IccProfileParser parser = new IccProfileParser();
    IccProfileInfo info = parser.getICCProfileInfo(bytes);
    if (info == null)
        return null;
    if (info.issRGB())
        return null;

    ICC_Profile icc = ICC_Profile.getInstance(bytes);
    return icc;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:17,代码来源:Sanselan.java


示例19: removeExifMetadata

import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
/** 
 * Reads a Jpeg image, removes all EXIF metadata (by removing the APP1 segment),
 * and writes the result to a stream.
 * <p>
 * @param  byteSource  ByteSource containing Jpeg image data.
 * @param  os  OutputStream to write the image to.
 */
public void removeExifMetadata(ByteSource byteSource, OutputStream os)
		throws ImageReadException, IOException, ImageWriteException
{
	JFIFPieces jfifPieces = analyzeJFIF(byteSource);
	List pieces = jfifPieces.pieces;

	//		Debug.debug("pieces", pieces);

	//		pieces.removeAll(jfifPieces.exifSegments);

	//		Debug.debug("pieces", pieces);

	writeSegmentsReplacingExif(os, pieces, null);
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:22,代码来源:ExifRewriter.java


示例20: getICCProfileBytes

import org.apache.sanselan.common.byteSources.ByteSource; //导入依赖的package包/类
public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	ArrayList segments = readSegments(byteSource,
			new int[] { JPEG_APP2_Marker, }, false);

	if (segments != null)
	{
		// throw away non-icc profile app2 segments.
		ArrayList filtered = new ArrayList();
		for (int i = 0; i < segments.size(); i++)
		{
			App2Segment segment = (App2Segment) segments.get(i);
			if (segment.icc_bytes != null)
				filtered.add(segment);
		}
		segments = filtered;
	}

	if ((segments == null) || (segments.size() < 1))
		return null;

	byte bytes[] = assembleSegments(segments);

	if (debug)
		System.out.println("bytes" + ": "
				+ ((bytes == null) ? null : "" + bytes.length));

	if (debug)
		System.out.println("");

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Collection类代码示例发布时间:2022-05-22
下一篇:
Java SpoonFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap