Mercurial > octave-libtiff
comparison scripts/io/Tiff.m @ 31131:7349994f30f8
Tiff: fixed the first test to use a single-pixel image
* Tiff.m: modified the test to use an image with one pixel instead
of an empty image.
* __tiff__.cc: fixed bugs in PlanarConfiguration tag and in type checking
for writeEncodedStrip.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Mon, 25 Jul 2022 04:15:18 +0200 |
parents | 7851c5b9c950 |
children | c66f7c227e50 |
comparison
equal
deleted
inserted
replaced
31130:8475bdb70457 | 31131:7349994f30f8 |
---|---|
1 classdef Tiff | 1 classdef Tiff |
2 properties (Constant = true) | 2 properties (Constant = true) |
3 % TODO(maged): Add the remaining fields | |
4 TagID = struct( | 3 TagID = struct( |
5 "SubFileType", 254, | 4 "SubFileType", 254, |
6 "ImageWidth", 256, | 5 "ImageWidth", 256, |
7 "ImageLength", 257, | 6 "ImageLength", 257, |
8 "BitsPerSample", 258, | 7 "BitsPerSample", 258, |
110 | 109 |
111 % TODO(maged): add documentation and make print_usage work | 110 % TODO(maged): add documentation and make print_usage work |
112 endmethods | 111 endmethods |
113 endclassdef | 112 endclassdef |
114 | 113 |
115 ## test empty image | 114 ## test one-pixel image |
116 %!testif HAVE_TIFF | 115 %!testif HAVE_TIFF |
117 %! filename = [tempname() ".tif"]; | 116 %! filename = [tempname() ".tif"]; |
118 %! unwind_protect | 117 %! unwind_protect |
119 %! a = Tiff (filename, "w"); | 118 %! a = Tiff (filename, "w"); |
119 %! setTag(a, "ImageWidth", 1); | |
120 %! setTag(a, "ImageLength", 1); | |
121 %! setTag(a, "BitsPerSample", 8); | |
122 %! data = uint8([255]); | |
123 %! writeEncodedStrip(a, 1, data); | |
120 %! a.close (); | 124 %! a.close (); |
121 %! a = Tiff (filename, "rh"); | 125 %! a = Tiff (filename, "r"); |
126 %! data2 = a.read(); | |
127 %! assert (all (size(data) == [1, 1])); | |
128 %! assert (data(1) == 255); | |
122 %! a.close (); | 129 %! a.close (); |
123 %! unwind_protect_cleanup | 130 %! unwind_protect_cleanup |
124 %! unlink (filename); | 131 %! unlink (filename); |
125 %! end_unwind_protect | 132 %! end_unwind_protect |