Mercurial > octave-libtiff
annotate libinterp/dldfcn/__tiff__.cc @ 31094:ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Wed, 22 Jun 2022 23:32:22 +0200 |
parents | e2bed4daae82 |
children | edfedae9972a |
rev | line source |
---|---|
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
1 #include <string> |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
2 #include <iostream> |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
3 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
4 #include "defun-dld.h" |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
5 #include "ov.h" |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
6 #include "ovl.h" |
31093
e2bed4daae82
Fix typo in module-files
magedrifaat <magedrifaat@gmail.com>
parents:
31092
diff
changeset
|
7 #include "error.h" |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
8 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
9 #include <tiffio.h> |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
10 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
11 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
12 // TODO(maged): Tidy up the formatting to be consistant with octave |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
13 |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
14 octave_value interpret_data(void *data, uint32_t count, TIFFDataType tag_datatype) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
15 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
16 // TODO(maged): Find the correct way fo returning multivalues |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
17 octave_value_list ov_data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
18 switch (tag_datatype) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
19 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
20 case TIFF_BYTE: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
21 case TIFF_UNDEFINED: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
22 for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
23 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
24 ov_data(i) = octave_value(((uint8_t *)data)[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
25 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
26 break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
27 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
28 case TIFF_ASCII: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
29 ov_data(0) = octave_value((char *)data); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
30 break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
31 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
32 case TIFF_SHORT: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
33 for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
34 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
35 ov_data(i) = octave_value(((uint16_t *)data)[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
36 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
37 break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
38 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
39 case TIFF_LONG: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
40 for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
41 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
42 ov_data(i) = octave_value(((uint32_t *)data)[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
43 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
44 break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
45 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
46 // case TIFF_RATIONAL: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
47 // uint32_t *u32data = (uint32_t *)data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
48 // for (uint32_t i = 0; i < count; i+=2) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
49 // { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
50 // ov_data(i / 2) = octave_value((float)u32data[i] / (float)u32data[i+1]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
51 // } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
52 // break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
53 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
54 // case TIFF_SBYTE: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
55 // int8_t *s8data = (int8_t *)data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
56 // for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
57 // { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
58 // ov_data(i) = octave_value(s8data[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
59 // } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
60 // break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
61 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
62 // case TIFF_SSHORT: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
63 // int16_t *s16data = (int16_t *)data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
64 // for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
65 // { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
66 // ov_data(i) = octave_value(s16data[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
67 // } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
68 // break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
69 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
70 // case TIFF_SLONG: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
71 // int32_t *s32data = (int32_t *)data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
72 // for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
73 // { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
74 // ov_data(i) = octave_value(s32data[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
75 // } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
76 // break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
77 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
78 // case TIFF_FLOAT: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
79 // float *float_data = (float *)data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
80 // for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
81 // { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
82 // ov_data(i) = octave_value(double_data[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
83 // } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
84 // break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
85 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
86 // case TIFF_DOUBLE: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
87 // double *double_data = (double *)data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
88 // for (uint32_t i = 0; i < count; i++) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
89 // { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
90 // ov_data(i) = octave_value(double_data[i]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
91 // } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
92 // break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
93 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
94 // case TIFF_SRATIONAL: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
95 // int32_t *s32data = (int32_t *)data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
96 // for (uint32_t i = 0; i < count; i+=2) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
97 // { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
98 // ov_data(i / 2) = octave_value((float)s32data[i] / (float)s32data[i+1]); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
99 // } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
100 // break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
101 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
102 case TIFF_IFD: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
103 // TODO(maged): implement IFD datatype |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
104 error("Unimplemented IFFD data type"); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
105 break; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
106 default: |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
107 // TODO(maged): find the correct response in this case |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
108 error("Unsupported tag data type"); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
109 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
110 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
111 return octave_value(ov_data); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
112 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
113 |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
114 DEFUN_DLD (__open_tiff__, args, nargout, |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
115 "Open a Tiff file and return its handle") |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
116 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
117 int nargin = args.length(); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
118 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
119 if (nargin == 0 || nargin > 2) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
120 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
121 // TODO(maged): return invalid object instead?? |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
122 error("No filename supplied\n"); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
123 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
124 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
125 std::string filename = args(0).string_value(); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
126 std::string mode = "r"; |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
127 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
128 // TODO(maged): check valid mode |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
129 if (nargin == 2) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
130 mode = args(1).string_value(); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
131 |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
132 // TODO(maged): Look into unwind action |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
133 TIFF *tif = TIFFOpen(filename.c_str(), mode.c_str()); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
134 // TODO(maged): print a better error |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
135 if (!tif) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
136 error("Failed to open Tiff file\n"); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
137 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
138 octave_value tiff_ov = octave_value((uint64_t)tif); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
139 return octave_value_list (tiff_ov); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
140 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
141 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
142 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
143 DEFUN_DLD (__close_tiff__, args, nargout, |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
144 "Close a tiff file") |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
145 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
146 int nargin = args.length(); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
147 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
148 if (nargin == 0) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
149 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
150 error("No handle provided\n"); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
151 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
152 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
153 TIFF *tif = (TIFF *)(args(0).uint64_value()); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
154 TIFFClose(tif); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
155 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
156 return octave_value_list (); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
157 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
158 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
159 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
160 DEFUN_DLD (__tiff_get_tag__, args, nargout, |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
161 "Get the value of a tag from a tiff image") |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
162 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
163 int nargin = args.length(); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
164 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
165 if (nargin == 0) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
166 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
167 error("No handle provided\n"); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
168 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
169 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
170 if (nargin < 2) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
171 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
172 error("No tag name provided\n"); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
173 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
174 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
175 TIFF *tif = (TIFF *)(args(0).uint64_value()); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
176 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
177 uint32_t tag_ID; |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
178 const TIFFField *fip; |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
179 if (args(1).type_name() == "string") |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
180 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
181 std::string tagName = args(1).string_value(); |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
182 fip = TIFFFieldWithName(tif, tagName.c_str()); |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
183 if (!fip) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
184 error("Tiff tag not found\n"); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
185 |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
186 tag_ID = TIFFFieldTag(fip); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
187 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
188 else |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
189 { |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
190 tag_ID = args(1).int_value(); |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
191 fip = TIFFFieldWithTag(tif, tag_ID); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
192 // TODO(maged): Handle other types of errors (e.g. unsupported tags) |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
193 if (!fip) |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
194 error("Tiff tag not found\n"); |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
195 } |
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
196 |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
197 TIFFDataType tag_datatype = TIFFFieldDataType(fip); |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
198 |
31094
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
199 int count = TIFFFieldReadCount(fip); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
200 octave_value tag_data_ov; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
201 void *data; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
202 if (count == TIFF_VARIABLE) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
203 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
204 uint16_t count_param; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
205 if (TIFFGetField(tif, tag_ID, &count_param, &data)) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
206 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
207 tag_data_ov = interpret_data(data, count_param, tag_datatype); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
208 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
209 else |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
210 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
211 // TODO(maged): Give a better error message? |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
212 error("Failed to read tag"); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
213 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
214 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
215 else if (count == TIFF_VARIABLE2) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
216 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
217 uint32_t count_param; |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
218 if (TIFFGetField(tif, tag_ID, &count_param, &data)) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
219 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
220 tag_data_ov = interpret_data(data, count_param, tag_datatype); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
221 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
222 else |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
223 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
224 // TODO(maged): Give a better error message? |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
225 error("Failed to read tag"); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
226 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
227 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
228 else if (count == TIFF_SPP) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
229 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
230 // TODO(maged): Handle TIFF_SPP |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
231 error("Unimplemented TIFF_SPP count"); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
232 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
233 else |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
234 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
235 int type_size = TIFFDataWidth(tag_datatype); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
236 data = _TIFFmalloc(type_size * count); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
237 // TODO(maged): This won't always work, e.g. string exepcts char ** |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
238 if (TIFFGetField(tif, tag_ID, data)) |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
239 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
240 tag_data_ov = interpret_data(data, count, tag_datatype); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
241 _TIFFfree(data); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
242 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
243 else |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
244 { |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
245 _TIFFfree(data); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
246 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
247 // TODO(maged): Give a better error message? |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
248 error("Failed to read tag"); |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
249 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
250 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
251 } |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
252 |
ab5b33e447b0
Modified getTag to account for different tag data types and multivalued tags, the current implementation is still buggy for most tags and data types
magedrifaat <magedrifaat@gmail.com>
parents:
31093
diff
changeset
|
253 return octave_value_list (octave_value(tag_data_ov)); |
31092
a736190ce738
Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff
changeset
|
254 } |