コード例 #1
0
  public void testCreation() {
    final TiffDirectoryEntrySet entrySet = new TiffDirectoryEntrySet();

    final TiffDirectoryEntry[] entries = entrySet.getEntries();
    assertNotNull(entries);
    assertEquals(0, entries.length);
  }
コード例 #2
0
  public void testSetEntry() {
    final TiffDirectoryEntrySet entrySet = new TiffDirectoryEntrySet();
    final TiffDirectoryEntry entry = new TiffDirectoryEntry(new TiffShort(45), new TiffLong(45678));

    entrySet.set(entry);

    final TiffDirectoryEntry[] entries = entrySet.getEntries();
    assertEquals(1, entries.length);
    assertSame(entry, entries[0]);
  }
コード例 #3
0
  public void testSetEntry_ReplaceAndOrderEntries() {
    final TiffDirectoryEntrySet entrySet = new TiffDirectoryEntrySet();
    final TiffDirectoryEntry entry1 =
        new TiffDirectoryEntry(new TiffShort(45), new TiffLong(45678));
    final TiffDirectoryEntry entry2 = new TiffDirectoryEntry(new TiffShort(43), new TiffLong(4234));
    final TiffDirectoryEntry entry3 =
        new TiffDirectoryEntry(new TiffShort(45), new TiffLong(42634));

    entrySet.set(entry1);
    entrySet.set(entry2);
    entrySet.set(entry3);

    final TiffDirectoryEntry[] entries = entrySet.getEntries();
    assertEquals(2, entries.length);
    assertSame(entry2, entries[0]);
    assertSame(entry3, entries[1]);
  }
コード例 #4
0
 public long getRequiredReferencedValuesSize() {
   final TiffDirectoryEntry[] entries = entrySet.getEntries();
   long size = 0;
   for (final TiffDirectoryEntry entry : entries) {
     if (entry.mustValuesBeReferenced()) {
       size += entry.getValuesSizeInBytes();
     }
   }
   return size;
 }
コード例 #5
0
 private void computeOffsets(final long ifdOffset) {
   final TiffDirectoryEntry[] entries = entrySet.getEntries();
   long valuesOffset = computeStartOffsetForValues(entries.length, ifdOffset);
   for (final TiffDirectoryEntry entry : entries) {
     if (entry.mustValuesBeReferenced()) {
       entry.setValuesOffset(valuesOffset);
       valuesOffset += entry.getValuesSizeInBytes();
     }
   }
   moveStripsTo(valuesOffset);
 }
コード例 #6
0
 public void write(final ImageOutputStream ios, final long ifdOffset, final long nextIfdOffset)
     throws IOException {
   Guardian.assertGreaterThan("ifdOffset", ifdOffset, -1);
   computeOffsets(ifdOffset);
   ios.seek(ifdOffset);
   final TiffDirectoryEntry[] entries = entrySet.getEntries();
   new TiffShort(entries.length).write(ios);
   long entryPosition = ios.getStreamPosition();
   for (TiffDirectoryEntry entry : entries) {
     ios.seek(entryPosition);
     entry.write(ios);
     entryPosition += TiffDirectoryEntry.BYTES_PER_ENTRY;
   }
   writeNextIfdOffset(ios, ifdOffset, nextIfdOffset);
 }
コード例 #7
0
  public void testGetEntry() {
    final TiffDirectoryEntrySet entrySet = new TiffDirectoryEntrySet();
    final TiffShort tag1 = new TiffShort(45);
    final TiffDirectoryEntry entry1 = new TiffDirectoryEntry(tag1, new TiffLong(45678));
    final TiffShort tag2 = new TiffShort(60);
    final TiffDirectoryEntry entry2 = new TiffDirectoryEntry(tag2, new TiffLong(4234));
    final TiffShort tag3 = new TiffShort(44);
    final TiffDirectoryEntry entry3 = new TiffDirectoryEntry(tag3, new TiffLong(42634));
    final TiffShort noEntryTag = new TiffShort(66);

    entrySet.set(entry1);
    entrySet.set(entry2);
    entrySet.set(entry3);

    assertEquals(entry1, entrySet.getEntry(tag1));
    assertEquals(entry2, entrySet.getEntry(tag2));
    assertEquals(entry3, entrySet.getEntry(tag3));
    assertNull(entrySet.getEntry(noEntryTag));
  }
コード例 #8
0
 public long getRequiredIfdSize() {
   final TiffDirectoryEntry[] entries = entrySet.getEntries();
   return BYTES_FOR_NUMBER_OF_ENTRIES
       + entries.length * TiffDirectoryEntry.BYTES_PER_ENTRY
       + BYTES_FOR_NEXT_IFD_OFFSET;
 }
コード例 #9
0
 public TiffDirectoryEntry getEntry(final TiffShort tag) {
   return entrySet.getEntry(tag);
 }
コード例 #10
0
 private void setEntry(final TiffDirectoryEntry entry) {
   entrySet.set(entry);
 }