1 | /*
|
---|
2 | * This is public domain software - that is, you can do whatever you want
|
---|
3 | * with it, and include it software that is licensed under the GNU or the
|
---|
4 | * BSD license, or whatever other licence you choose, including proprietary
|
---|
5 | * closed source licenses. I do ask that you leave this header in tact.
|
---|
6 | *
|
---|
7 | * If you make modifications to this code that you think would benefit the
|
---|
8 | * wider community, please send me a copy and I'll post it on my site.
|
---|
9 | *
|
---|
10 | * If you make use of this code, I'd appreciate hearing about it.
|
---|
11 | * drew@drewnoakes.com
|
---|
12 | * Latest version of this software kept at
|
---|
13 | * http://drewnoakes.com/
|
---|
14 | *
|
---|
15 | * Created by dnoakes on Oct 9, 17:04:07 using IntelliJ IDEA.
|
---|
16 | */
|
---|
17 | package com.drew.metadata.jpeg;
|
---|
18 |
|
---|
19 | import com.drew.metadata.MetadataException;
|
---|
20 |
|
---|
21 | import java.io.Serializable;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Created by IntelliJ IDEA.
|
---|
25 | * User: dnoakes
|
---|
26 | * Date: 09-Oct-2003
|
---|
27 | * Time: 17:04:07
|
---|
28 | * To change this template use Options | File Templates.
|
---|
29 | */
|
---|
30 | public class JpegComponent implements Serializable
|
---|
31 | {
|
---|
32 | private final int _componentId;
|
---|
33 | private final int _samplingFactorByte;
|
---|
34 | private final int _quantizationTableNumber;
|
---|
35 |
|
---|
36 | public JpegComponent(int componentId, int samplingFactorByte, int quantizationTableNumber)
|
---|
37 | {
|
---|
38 | _componentId = componentId;
|
---|
39 | _samplingFactorByte = samplingFactorByte;
|
---|
40 | _quantizationTableNumber = quantizationTableNumber;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public int getComponentId()
|
---|
44 | {
|
---|
45 | return _componentId;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public String getComponentName() throws MetadataException
|
---|
49 | {
|
---|
50 | switch (_componentId)
|
---|
51 | {
|
---|
52 | case 1:
|
---|
53 | return "Y";
|
---|
54 | case 2:
|
---|
55 | return "Cb";
|
---|
56 | case 3:
|
---|
57 | return "Cr";
|
---|
58 | case 4:
|
---|
59 | return "I";
|
---|
60 | case 5:
|
---|
61 | return "Q";
|
---|
62 | }
|
---|
63 |
|
---|
64 | throw new MetadataException("Unsupported component id: " + _componentId);
|
---|
65 | }
|
---|
66 |
|
---|
67 | public int getQuantizationTableNumber()
|
---|
68 | {
|
---|
69 | return _quantizationTableNumber;
|
---|
70 | }
|
---|
71 |
|
---|
72 | public int getHorizontalSamplingFactor()
|
---|
73 | {
|
---|
74 | return _samplingFactorByte & 0x0F;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public int getVerticalSamplingFactor()
|
---|
78 | {
|
---|
79 | return (_samplingFactorByte>>4) & 0x0F;
|
---|
80 | }
|
---|
81 | }
|
---|