1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.imaging.formats.tiff.taginfos;
18
19 import java.nio.ByteOrder;
20
21 import org.apache.commons.imaging.common.ByteConversions;
22 import org.apache.commons.imaging.common.RationalNumber;
23 import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
24 import org.apache.commons.imaging.formats.tiff.fieldtypes.AbstractFieldType;
25
26 public class TagInfoRational extends TagInfo {
27 public TagInfoRational(final String name, final int tag, final TiffDirectoryType directoryType) {
28 super(name, tag, AbstractFieldType.RATIONAL, 1, directoryType);
29 }
30
31 public byte[] encodeValue(final ByteOrder byteOrder, final RationalNumber value) {
32 return ByteConversions.toBytes(value, byteOrder);
33 }
34
35 public RationalNumber getValue(final ByteOrder byteOrder, final byte[] bytes) {
36 return ByteConversions.toRational(bytes, byteOrder, true);
37 }
38 }