Debian Codegraph @

src/com/drew/metadata/mov/atoms/TextSampleDescriptionAtom.java

raw symbols SCIP
1 /*
2 * Copyright 2002-2019 Drew Noakes and contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * https://drewnoakes.com/code/exif/
19 * https://github.com/drewnoakes/metadata-extractor
20 */
21 package com.drew.metadata.mov.atoms;
22
23 import com.drew.lang.SequentialReader;
24 import com.drew.lang.annotations.NotNull;
25 import com.drew.metadata.mov.media.QuickTimeTextDirectory;
26
27 import java.io.IOException;
28
29 /**
30 * https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-57428
31 *
32 * @author Payton Garland
33 */
34 public class TextSampleDescriptionAtom extends SampleDescriptionAtom<TextSampleDescriptionAtom.TextSampleDescription>
35 {
36 public TextSampleDescriptionAtom(SequentialReader reader, Atom atom) throws IOException
37 {
38 super(reader, atom);
39 }
40
41 @NotNull
42 @Override
43 TextSampleDescription getSampleDescription(SequentialReader reader) throws IOException
44 {
45 return new TextSampleDescription(reader);
46 }
47
48 public void addMetadata(QuickTimeTextDirectory directory)
49 {
50 if (sampleDescriptions.size() == 0) {
51 return;
52 }
53
54 TextSampleDescription description = sampleDescriptions.get(0);
55
56 directory.setBoolean(QuickTimeTextDirectory.TAG_AUTO_SCALE, (description.displayFlags & 0x0002) == 0x0002);
57
58 directory.setBoolean(QuickTimeTextDirectory.TAG_MOVIE_BACKGROUND_COLOR, (description.displayFlags & 0x0008) == 0x0008);
59
60 directory.setBoolean(QuickTimeTextDirectory.TAG_SCROLL_IN, (description.displayFlags & 0x0020) == 0x0020);
61
62 directory.setBoolean(QuickTimeTextDirectory.TAG_SCROLL_OUT, (description.displayFlags & 0x0040) == 0x0040);
63
64 directory.setString(QuickTimeTextDirectory.TAG_HORIZONTAL_SCROLL, ((description.displayFlags & 0x0080) == 0x0080) ? "Horizontal" : "Vertical");
65
66 directory.setString(QuickTimeTextDirectory.TAG_REVERSE_SCROLL, ((description.displayFlags & 0x0100) == 0x0100) ? "Reverse" : "Normal");
67
68 directory.setBoolean(QuickTimeTextDirectory.TAG_CONTINUOUS_SCROLL, (description.displayFlags & 0x0200) == 0x0200);
69
70 directory.setBoolean(QuickTimeTextDirectory.TAG_DROP_SHADOW, (description.displayFlags & 0x1000) == 0x1000);
71
72 directory.setBoolean(QuickTimeTextDirectory.TAG_ANTI_ALIAS, (description.displayFlags & 0x2000) == 0x2000);
73
74 directory.setBoolean(QuickTimeTextDirectory.TAG_KEY_TEXT, (description.displayFlags & 0x4000) == 0x4000);
75
76 switch (description.textJustification) {
77 case (0):
78 directory.setString(QuickTimeTextDirectory.TAG_JUSTIFICATION, "Left");
79 break;
80 case (1):
81 directory.setString(QuickTimeTextDirectory.TAG_JUSTIFICATION, "Center");
82 break;
83 case (-1):
84 directory.setString(QuickTimeTextDirectory.TAG_JUSTIFICATION, "Right");
85 }
86
87 directory.setIntArray(QuickTimeTextDirectory.TAG_BACKGROUND_COLOR, description.backgroundColor);
88 directory.setLong(QuickTimeTextDirectory.TAG_DEFAULT_TEXT_BOX, description.defaultTextBox);
89 directory.setInt(QuickTimeTextDirectory.TAG_FONT_NUMBER, description.fontNumber);
90
91 switch (description.fontFace) {
92 case (0x0001):
93 directory.setString(QuickTimeTextDirectory.TAG_FONT_FACE, "Bold");
94 break;
95 case (0x0002):
96 directory.setString(QuickTimeTextDirectory.TAG_FONT_FACE, "Italic");
97 break;
98 case (0x0004):
99 directory.setString(QuickTimeTextDirectory.TAG_FONT_FACE, "Underline");
100 break;
101 case (0x0008):
102 directory.setString(QuickTimeTextDirectory.TAG_FONT_FACE, "Outline");
103 break;
104 case (0x0010):
105 directory.setString(QuickTimeTextDirectory.TAG_FONT_FACE, "Shadow");
106 break;
107 case (0x0020):
108 directory.setString(QuickTimeTextDirectory.TAG_FONT_FACE, "Condense");
109 break;
110 case (0x0040):
111 directory.setString(QuickTimeTextDirectory.TAG_FONT_FACE, "Extend");
112 }
113
114 directory.setIntArray(QuickTimeTextDirectory.TAG_FOREGROUND_COLOR, description.foregroundColor);
115 directory.setString(QuickTimeTextDirectory.TAG_NAME, description.textName);
116 }
117
118 static class TextSampleDescription extends SampleDescription
119 {
120 int displayFlags;
121 int textJustification;
122 int[] backgroundColor;
123 long defaultTextBox;
124 int fontNumber;
125 int fontFace;
126 int[] foregroundColor;
127 String textName;
128
129 public TextSampleDescription(SequentialReader reader) throws IOException
130 {
131 super(reader);
132
133 displayFlags = reader.getInt32();
134 textJustification = reader.getInt32();
135 backgroundColor = new int[]{reader.getUInt16(), reader.getUInt16(), reader.getUInt16()};
136 defaultTextBox = reader.getInt64();
137 reader.skip(8); // 64-bits of reserved space set to 0
138 fontNumber = reader.getUInt16();
139 fontFace = reader.getUInt16();
140 reader.skip(1); // 8-bits of reserved space set to 0
141 reader.skip(2); // 16-bits of reserved space set to 0
142 foregroundColor = new int[]{reader.getUInt16(), reader.getUInt16(), reader.getUInt16()};
143 textName = reader.getString(reader.getUInt8());
144 }
145 }
146 }