| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 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 |
|
| 31 |
|
| 32 |
|
| 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); |
| 138 |
fontNumber = reader.getUInt16(); |
| 139 |
fontFace = reader.getUInt16(); |
| 140 |
reader.skip(1); |
| 141 |
reader.skip(2); |
| 142 |
foregroundColor = new int[]{reader.getUInt16(), reader.getUInt16(), reader.getUInt16()}; |
| 143 |
textName = reader.getString(reader.getUInt8()); |
| 144 |
} |
| 145 |
} |
| 146 |
} |