public void testCreation() {
    final TiffDirectoryEntrySet entrySet = new TiffDirectoryEntrySet();

    final TiffDirectoryEntry[] entries = entrySet.getEntries();
    assertNotNull(entries);
    assertEquals(0, entries.length);
  }
  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]);
  }
  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]);
  }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
  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));
  }
Exemplo n.º 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;
 }
Exemplo n.º 9
0
 public TiffDirectoryEntry getEntry(final TiffShort tag) {
   return entrySet.getEntry(tag);
 }
Exemplo n.º 10
0
 private void setEntry(final TiffDirectoryEntry entry) {
   entrySet.set(entry);
 }