-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtiff_types_helper.go
108 lines (101 loc) · 1.94 KB
/
tiff_types_helper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2015 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tiff
func (p TiffType) Valid() bool {
return p == TiffType_ClassicTIFF || p == TiffType_BigTIFF
}
func (d DataType) Valid() bool {
if d <= DataType_Nil || d > DataType_IFD8 {
return false
}
_, ok := _DataTypeTable[d]
return ok
}
func (d DataType) IsIntType() bool {
switch d {
case DataType_Byte, DataType_Short, DataType_Long:
return true
case DataType_SByte, DataType_SShort, DataType_SLong:
return true
case DataType_IFD, DataType_IFD8:
return true
}
return false
}
func (d DataType) IsFloatType() bool {
switch d {
case DataType_Float, DataType_Double:
return true
}
return false
}
func (d DataType) IsRationalType() bool {
switch d {
case DataType_Rational, DataType_SRational:
return true
}
return false
}
func (d DataType) IsStringType() bool {
switch d {
case DataType_ASCII:
return true
}
return false
}
func (d DataType) ByteSize() int {
switch d {
case DataType_Byte:
return 1
case DataType_ASCII:
return 1
case DataType_Short:
return 2
case DataType_Long:
return 4
case DataType_Rational:
return 8
case DataType_SByte:
return 1
case DataType_Undefined:
return 1
case DataType_SShort:
return 2
case DataType_SLong:
return 4
case DataType_SRational:
return 8
case DataType_Float:
return 4
case DataType_Double:
return 8
case DataType_IFD:
return 4 // LONG
case DataType_Long8:
return 8
case DataType_SLong8:
return 8
case DataType_IFD8:
return 8 // LONG8
}
return 0
}
func (d TagType) _AcceptDataType(dataType DataType) bool {
if !dataType.Valid() {
return false
}
dataTypeList, _ := _TagType_TypesTable[d]
if len(dataTypeList) == 0 {
return true
}
for _, v := range dataTypeList {
if v == dataType {
return true
}
}
return false
}
func (d TagType) Valid() bool {
return d != 0
}