本文整理汇总了Java中com.adobe.xmp.XMPMetaFactory.parseFromBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java XMPMetaFactory.parseFromBuffer方法的具体用法?Java XMPMetaFactory.parseFromBuffer怎么用?Java XMPMetaFactory.parseFromBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.adobe.xmp.XMPMetaFactory
的用法示例。
在下文中一共展示了XMPMetaFactory.parseFromBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import com.adobe.xmp.XMPMetaFactory; //导入方法依赖的package包/类
/**
* Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
* <p>
* The extraction is done with Adobe's XMPCore library.
*/
public void extract(@NotNull final byte[] xmpBytes, int offset, int length, @NotNull Metadata metadata, @Nullable Directory parentDirectory)
{
XmpDirectory directory = new XmpDirectory();
if (parentDirectory != null)
directory.setParent(parentDirectory);
try {
XMPMeta xmpMeta;
// If all xmpBytes are requested, no need to make a new ByteBuffer
if (offset == 0 && length == xmpBytes.length) {
xmpMeta = XMPMetaFactory.parseFromBuffer(xmpBytes);
} else {
ByteBuffer buffer = new ByteBuffer(xmpBytes, offset, length);
xmpMeta = XMPMetaFactory.parse(buffer.getByteStream());
}
directory.setXMPMeta(xmpMeta);
} catch (XMPException e) {
directory.addError("Error processing XMP data: " + e.getMessage());
}
if (!directory.isEmpty())
metadata.addDirectory(directory);
}
示例2: extractXMPMeta
import com.adobe.xmp.XMPMetaFactory; //导入方法依赖的package包/类
/**
* Extracts XMPMeta from a JPEG image file stream.
*
* @param is the input stream containing the JPEG image file.
* @return Extracted XMPMeta or null.
*/
public static XMPMeta extractXMPMeta(InputStream is) {
List<Section> sections = parse(is, true);
if (sections == null) {
return null;
}
// Now we don't support extended xmp.
for (Section section : sections) {
if (hasXMPHeader(section.data)) {
int end = getXMPContentEnd(section.data);
byte[] buffer = new byte[end - XMP_HEADER_SIZE];
System.arraycopy(
section.data, XMP_HEADER_SIZE, buffer, 0, buffer.length);
try {
XMPMeta result = XMPMetaFactory.parseFromBuffer(buffer);
return result;
} catch (XMPException e) {
Log.d(TAG, "XMP parse error", e);
return null;
}
}
}
return null;
}
示例3: extract
import com.adobe.xmp.XMPMetaFactory; //导入方法依赖的package包/类
/**
* Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}.
* <p/>
* The extraction is done with Adobe's XMPCore library.
*/
public void extract(@NotNull final byte[] xmpBytes, @NotNull Metadata metadata)
{
XmpDirectory directory = metadata.getOrCreateDirectory(XmpDirectory.class);
try {
XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(xmpBytes);
processXmpTags(directory, xmpMeta);
} catch (XMPException e) {
directory.addError("Error processing XMP data: " + e.getMessage());
}
}