summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/mpo/MpoIfdData.java
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-02-22 16:38:13 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-04-12 17:14:12 -0700
commitabfa9e762b0b6d298726ecd46c8d7fd59b69b957 (patch)
tree0afabcc7eef8d8bf53d2e9ef211a1c90af3b2c78 /src/com/android/camera/mpo/MpoIfdData.java
parent4b33265c83966f70d4ef5cbe5c182d7dc670e5ee (diff)
downloadandroid_packages_apps_Snap-abfa9e762b0b6d298726ecd46c8d7fd59b69b957.tar.gz
android_packages_apps_Snap-abfa9e762b0b6d298726ecd46c8d7fd59b69b957.tar.bz2
android_packages_apps_Snap-abfa9e762b0b6d298726ecd46c8d7fd59b69b957.zip
SnapdragonCamera: Add support for outputting MPO format files
Add support for generating MPO formatted files from the application layer. CRs-Fixed: 993611 Change-Id: I9a78d33e1d80b7da748f9bc75446f49172342078
Diffstat (limited to 'src/com/android/camera/mpo/MpoIfdData.java')
-rw-r--r--src/com/android/camera/mpo/MpoIfdData.java126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/com/android/camera/mpo/MpoIfdData.java b/src/com/android/camera/mpo/MpoIfdData.java
new file mode 100644
index 000000000..8e422944a
--- /dev/null
+++ b/src/com/android/camera/mpo/MpoIfdData.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Not a contribution.
+ *
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.mpo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class stores all the tags in an MP Index IFD.
+ */
+public class MpoIfdData {
+ public static final int TYPE_MP_INDEX_IFD = 1;
+ public static final int TYPE_MP_ATTRIB_IFD = 2;
+ public static final byte[] MP_FORMAT_VER_VALUE = { 0x30, 0x31, 0x30, 0x30 };
+
+ private final int mIfdId;
+ private final Map<Short, MpoTag> mTags = new HashMap<Short, MpoTag>();
+ private int mOffsetToNextIfd = 0;
+
+ /**
+ * Creates an empty MpIndexIfdData
+ */
+ public MpoIfdData(int ifdId) {
+ mIfdId = ifdId;
+ }
+
+ /**
+ * Get a array the contains all {@link MpoTag} in this IFD.
+ */
+ protected MpoTag[] getAllTags() {
+ return mTags.values().toArray(new MpoTag[mTags.size()]);
+ }
+
+ /**
+ * Gets the {@link MpoTag} with given tag id. Return null if there is no
+ * such tag.
+ */
+ protected MpoTag getTag(short tagId) {
+ return mTags.get(tagId);
+ }
+
+ /**
+ * Adds or replaces a {@link MpoTag}.
+ */
+ protected MpoTag setTag(MpoTag tag) {
+ tag.setIfd(mIfdId);
+ return mTags.put(tag.getTagId(), tag);
+ }
+
+ protected boolean checkCollision(short tagId) {
+ return mTags.get(tagId) != null;
+ }
+
+ /**
+ * Removes the tag of the given ID
+ */
+ protected void removeTag(short tagId) {
+ mTags.remove(tagId);
+ }
+
+ /**
+ * Gets the tags count in the IFD.
+ */
+ protected int getTagCount() {
+ return mTags.size();
+ }
+
+ /**
+ * Sets the offset of next IFD.
+ */
+ protected void setOffsetToNextIfd(int offset) {
+ mOffsetToNextIfd = offset;
+ }
+
+ /**
+ * Gets the offset of next IFD.
+ */
+ protected int getOffsetToNextIfd() {
+ return mOffsetToNextIfd;
+ }
+
+ /**
+ * Returns true if all tags in this two IFDs are equal. Note that tags of
+ * IFD offset will be ignored.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (obj instanceof MpoIfdData) {
+ MpoIfdData data = (MpoIfdData) obj;
+ if (data.getTagCount() == getTagCount()) {
+ MpoTag[] tags = data.getAllTags();
+ for (MpoTag tag : tags) {
+ MpoTag tag2 = mTags.get(tag.getTagId());
+ if (!tag.equals(tag2)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+}