public TiffOutputDirectory getOutputDirectory(int byteOrder)
throws ImageWriteException
{
try
{
TiffOutputDirectory dstDir = new TiffOutputDirectory(type);
ArrayList entries = getItems();
for (int i = 0; i < entries.size(); i++)
{
TiffImageMetadata.Item item = (TiffImageMetadata.Item) entries
.get(i);
TiffField srcField = item.getTiffField();
if (null != dstDir.findField(srcField.tag))
{
// ignore duplicate tags in a directory.
continue;
}
else if (srcField.tagInfo instanceof TagInfo.Offset)
{
// ignore offset fields.
continue;
}
TagInfo tagInfo = srcField.tagInfo;
FieldType fieldType = srcField.fieldType;
int count = srcField.length;
// byte bytes[] = srcField.fieldType.getRawBytes(srcField);
// Debug.debug("tagInfo", tagInfo);
Object value = srcField.getValue();
// Debug.debug("value", Debug.getType(value));
byte bytes[] = tagInfo.encodeValue(fieldType, value,
byteOrder);
// if (tagInfo.isUnknown())
// Debug.debug(
// "\t" + "unknown tag(0x"
// + Integer.toHexString(srcField.tag)
// + ") bytes", bytes);
TiffOutputField dstField = new TiffOutputField(
srcField.tag, tagInfo, fieldType, count, bytes);
dstField.setSortHint(srcField.getSortHint());
dstDir.add(dstField);
}
dstDir.setTiffImageData(getTiffImageData());
dstDir.setJpegImageData(getJpegImageData());
return dstDir;
}
catch (ImageReadException e)
{