Methods Summary |
---|
protected void | addIfdData(IfdData data)Adds IFD data. If IFD data of the same type already exists, it will be
replaced by the new data.
mIfdDatas[data.getId()] = data;
|
protected ExifTag | addTag(ExifTag tag)Adds the given ExifTag to its default IFD and returns an existing ExifTag
with the same TID or null if none exist.
if (tag != null) {
int ifd = tag.getIfd();
return addTag(tag, ifd);
}
return null;
|
protected ExifTag | addTag(ExifTag tag, int ifdId)Adds the given ExifTag to the given IFD and returns an existing ExifTag
with the same TID or null if none exist.
if (tag != null && ExifTag.isValidIfd(ifdId)) {
IfdData ifdData = getOrCreateIfdData(ifdId);
return ifdData.setTag(tag);
}
return null;
|
protected void | clearThumbnailAndStrips()
mThumbnail = null;
mStripBytes.clear();
|
public boolean | equals(java.lang.Object obj)
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (obj instanceof ExifData) {
ExifData data = (ExifData) obj;
if (data.mByteOrder != mByteOrder ||
data.mStripBytes.size() != mStripBytes.size() ||
!Arrays.equals(data.mThumbnail, mThumbnail)) {
return false;
}
for (int i = 0; i < mStripBytes.size(); i++) {
if (!Arrays.equals(data.mStripBytes.get(i), mStripBytes.get(i))) {
return false;
}
}
for (int i = 0; i < IfdId.TYPE_IFD_COUNT; i++) {
IfdData ifd1 = data.getIfdData(i);
IfdData ifd2 = getIfdData(i);
if (ifd1 != ifd2 && ifd1 != null && !ifd1.equals(ifd2)) {
return false;
}
}
return true;
}
return false;
|
protected java.util.List | getAllTags()Returns a list of all {@link ExifTag}s in the ExifData or null if there
are none.
ArrayList<ExifTag> ret = new ArrayList<ExifTag>();
for (IfdData d : mIfdDatas) {
if (d != null) {
ExifTag[] tags = d.getAllTags();
if (tags != null) {
for (ExifTag t : tags) {
ret.add(t);
}
}
}
}
if (ret.size() == 0) {
return null;
}
return ret;
|
protected java.util.List | getAllTagsForIfd(int ifd)Returns a list of all {@link ExifTag}s in a given IFD or null if there
are none.
IfdData d = mIfdDatas[ifd];
if (d == null) {
return null;
}
ExifTag[] tags = d.getAllTags();
if (tags == null) {
return null;
}
ArrayList<ExifTag> ret = new ArrayList<ExifTag>(tags.length);
for (ExifTag t : tags) {
ret.add(t);
}
if (ret.size() == 0) {
return null;
}
return ret;
|
protected java.util.List | getAllTagsForTagId(short tag)Returns a list of all {@link ExifTag}s with a given TID or null if there
are none.
ArrayList<ExifTag> ret = new ArrayList<ExifTag>();
for (IfdData d : mIfdDatas) {
if (d != null) {
ExifTag t = d.getTag(tag);
if (t != null) {
ret.add(t);
}
}
}
if (ret.size() == 0) {
return null;
}
return ret;
|
protected java.nio.ByteOrder | getByteOrder()Gets the byte order.
return mByteOrder;
|
protected byte[] | getCompressedThumbnail()Gets the compressed thumbnail. Returns null if there is no compressed
thumbnail.
return mThumbnail;
|
protected IfdData | getIfdData(int ifdId)Returns the {@link IfdData} object corresponding to a given IFD if it
exists or null.
if (ExifTag.isValidIfd(ifdId)) {
return mIfdDatas[ifdId];
}
return null;
|
protected IfdData | getOrCreateIfdData(int ifdId)Returns the {@link IfdData} object corresponding to a given IFD or
generates one if none exist.
IfdData ifdData = mIfdDatas[ifdId];
if (ifdData == null) {
ifdData = new IfdData(ifdId);
mIfdDatas[ifdId] = ifdData;
}
return ifdData;
|
protected byte[] | getStrip(int index)Gets the strip at the specified index.
return mStripBytes.get(index);
|
protected int | getStripCount()Gets the strip count.
return mStripBytes.size();
|
protected ExifTag | getTag(short tag, int ifd)Returns the tag with a given TID in the given IFD if the tag exists.
Otherwise returns null.
IfdData ifdData = mIfdDatas[ifd];
return (ifdData == null) ? null : ifdData.getTag(tag);
|
protected java.lang.String | getUserComment()Decodes the user comment tag into string as specified in the EXIF
standard. Returns null if decoding failed.
IfdData ifdData = mIfdDatas[IfdId.TYPE_IFD_0];
if (ifdData == null) {
return null;
}
ExifTag tag = ifdData.getTag(ExifInterface.getTrueTagKey(ExifInterface.TAG_USER_COMMENT));
if (tag == null) {
return null;
}
if (tag.getComponentCount() < 8) {
return null;
}
byte[] buf = new byte[tag.getComponentCount()];
tag.getBytes(buf);
byte[] code = new byte[8];
System.arraycopy(buf, 0, code, 0, 8);
try {
if (Arrays.equals(code, USER_COMMENT_ASCII)) {
return new String(buf, 8, buf.length - 8, "US-ASCII");
} else if (Arrays.equals(code, USER_COMMENT_JIS)) {
return new String(buf, 8, buf.length - 8, "EUC-JP");
} else if (Arrays.equals(code, USER_COMMENT_UNICODE)) {
return new String(buf, 8, buf.length - 8, "UTF-16");
} else {
return null;
}
} catch (UnsupportedEncodingException e) {
Log.w(TAG, "Failed to decode the user comment");
return null;
}
|
protected boolean | hasCompressedThumbnail()Returns true it this header contains a compressed thumbnail.
return mThumbnail != null;
|
protected boolean | hasUncompressedStrip()Returns true if this header contains uncompressed strip.
return mStripBytes.size() != 0;
|
protected void | removeTag(short tagId, int ifdId)Removes the tag with a given TID and IFD.
IfdData ifdData = mIfdDatas[ifdId];
if (ifdData == null) {
return;
}
ifdData.removeTag(tagId);
|
protected void | removeThumbnailData()Removes the thumbnail and its related tags. IFD1 will be removed.
clearThumbnailAndStrips();
mIfdDatas[IfdId.TYPE_IFD_1] = null;
|
protected void | setCompressedThumbnail(byte[] thumbnail)Sets the compressed thumbnail.
mThumbnail = thumbnail;
|
protected void | setStripBytes(int index, byte[] strip)Adds an uncompressed strip.
if (index < mStripBytes.size()) {
mStripBytes.set(index, strip);
} else {
for (int i = mStripBytes.size(); i < index; i++) {
mStripBytes.add(null);
}
mStripBytes.add(strip);
}
|