author | HG Automerge |
Thu, 22 Dec 2016 23:11:31 +0000 | |
branch | jv |
changeset 3815 | 021778442c82 |
parent 1848 | 864ca2cd4e71 |
child 3855 | 1db7742d33ad |
permissions | -rw-r--r-- |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
1 |
" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
3 |
All Rights Reserved |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
4 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
5 |
This software is furnished under a license and may be used |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
10 |
hereby transferred. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
11 |
" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
12 |
|
2 | 13 |
|
1745
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
14 |
"{ Package: 'stx:libview2' }" |
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
15 |
|
2 | 16 |
ImageReader subclass:#PBMReader |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
17 |
instanceVariableNames:'maxVal' |
200 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
1745
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
20 |
category:'Graphics-Images-Readers' |
2 | 21 |
! |
22 |
||
21 | 23 |
!PBMReader class methodsFor:'documentation'! |
24 |
||
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
25 |
copyright |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
26 |
" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
27 |
COPYRIGHT (c) 1992 by Claus Gittinger |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
28 |
All Rights Reserved |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
29 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
30 |
This software is furnished under a license and may be used |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
31 |
only in accordance with the terms of that license and with the |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
32 |
inclusion of the above copyright notice. This software may not |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
33 |
be provided or otherwise made available to, or used by, any |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
34 |
other person. No title to or ownership of the software is |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
35 |
hereby transferred. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
36 |
" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
37 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
38 |
! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
39 |
|
21 | 40 |
documentation |
41 |
" |
|
32 | 42 |
this class provides methods for loading and saving Portable BitMap-file |
43 |
images (Jef Poskanzers portable bitmap package). |
|
200 | 44 |
|
46 | 45 |
Reading is supported for 1bit (pbm), greyscale (pgm) and 24bit (ppm) formats. |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
46 |
(i.e. P1, P3, P4, P5, P6 and P7 formats) |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
47 |
|
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
48 |
Writing is (currently) only supported for the binary formats; |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
49 |
i.e. 1-bit images as (pbm P4), 8-bit gray as (pgm P5) and 24-bit images as (pnm P6). |
46 | 50 |
|
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
51 |
Q: should we broil this one to perfection and base all others on |
46 | 52 |
pipe-readers to the various pbmplus converters ? |
200 | 53 |
|
54 |
[See also:] |
|
234 | 55 |
Image Form Icon |
200 | 56 |
BlitImageReader FaceReader GIFReader JPEGReader PCXReader |
210 | 57 |
ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader |
209 | 58 |
XBMReader XPMReader XWDReader |
21 | 59 |
" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
60 |
! ! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
61 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
62 |
!PBMReader class methodsFor:'initialization'! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
63 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
64 |
initialize |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
65 |
"install myself in the Image classes fileFormat table |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
66 |
for the `.pbm', '.pgm' and '.pnm' extensions." |
806 | 67 |
|
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
68 |
MIMETypes defineImageType:'image/x-portable-bitmap' suffix:'pbm' reader:self. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
69 |
MIMETypes defineImageType:'image/x-portable-graymap' suffix:'pgm' reader:self. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
70 |
MIMETypes defineImageType:'image/x-portable-anymap' suffix:'pnm' reader:self. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
71 |
MIMETypes defineImageType:'image/x-portable-pixmap' suffix:'ppm' reader:self. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
72 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
73 |
"Modified: / 1.2.1997 / 15:02:14 / cg" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
74 |
"Created: / 3.2.1998 / 17:19:59 / cg" |
21 | 75 |
! ! |
2 | 76 |
|
713 | 77 |
!PBMReader class methodsFor:'testing'! |
78 |
||
79 |
canRepresent:anImage |
|
80 |
"return true, if anImage can be represented in my file format. |
|
81 |
Currently, only 1bit B&W, 8bit-grey and 24bit RGB images are supported." |
|
82 |
||
83 |
|depth photometric| |
|
84 |
||
85 |
anImage photometric == #rgb ifTrue:[ |
|
86 |
^ depth==24 |
|
87 |
]. |
|
88 |
(depth := anImage depth) == 1 ifTrue:[^ true]. |
|
89 |
depth == 8 ifTrue:[ |
|
90 |
photometric := anImage photometric. |
|
91 |
^ (photometric == #blackIs0) or:[photometric == #whiteIs0] |
|
92 |
]. |
|
93 |
^ false |
|
94 |
||
95 |
"Modified: 17.10.1997 / 20:20:52 / cg" |
|
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
96 |
! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
97 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
98 |
isValidImageFile:aFileName |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
99 |
"return true, if aFileName contains a PBM image (which I can read)" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
100 |
|
1082 | 101 |
|inStream pnmType ok| |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
102 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
103 |
inStream := self streamReadingFile:aFileName. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
104 |
inStream isNil ifTrue:[^ false]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
105 |
inStream text. |
1082 | 106 |
ok := inStream next == $P. |
107 |
ok ifTrue:[ |
|
108 |
pnmType := inStream next. |
|
109 |
ok := #( $1 $3 $4 $5 $6 $7) includes:pnmType. |
|
110 |
]. |
|
111 |
inStream close. |
|
112 |
^ ok |
|
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
113 |
|
1082 | 114 |
"Modified: / 7.12.1998 / 14:27:11 / cg" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
115 |
! ! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
116 |
|
1848 | 117 |
!PBMReader methodsFor:'private-reading'! |
118 |
||
119 |
readMaxVal |
|
120 |
self skipPBMJunk. |
|
121 |
maxVal := Integer readFrom:inStream onError:nil. |
|
122 |
(maxVal isNil or:[maxVal >= 256]) ifTrue: [ |
|
123 |
self fileFormatError:'Invalid format'. |
|
124 |
^ false. |
|
125 |
]. |
|
126 |
^ true |
|
127 |
! |
|
128 |
||
129 |
readWidthAndHeight |
|
130 |
self skipPBMJunk. |
|
131 |
width := Integer readFrom:inStream onError:0. |
|
132 |
width > 0 ifFalse: [ |
|
133 |
self fileFormatError:'Invalid width'. |
|
134 |
^ false |
|
135 |
]. |
|
136 |
||
137 |
self skipPBMJunk. |
|
138 |
height := Integer readFrom:inStream onError:0. |
|
139 |
height > 0 ifFalse: [ |
|
140 |
self fileFormatError:'Invalid height'. |
|
141 |
^ false |
|
142 |
]. |
|
143 |
||
144 |
self reportDimension. |
|
145 |
^ true |
|
146 |
! |
|
147 |
||
148 |
readWidthAndHeightAndMaxVal |
|
149 |
(self readWidthAndHeight) ifFalse:[ ^ false ]. |
|
150 |
^ self readMaxVal |
|
151 |
! |
|
152 |
||
153 |
skipPBMJunk |
|
154 |
"this method removes any superfluous characters from the input stream." |
|
155 |
||
156 |
| char foundNL| |
|
157 |
||
158 |
[ |
|
159 |
char := inStream peek. |
|
160 |
[char == $#] whileTrue:[ |
|
161 |
"Start of a comment. Skip to end-of-line." |
|
162 |
"/ foundNL := (aStream skipUpTo: Character cr) notNil. |
|
163 |
foundNL := (inStream skipThrough: Character cr) notNil. |
|
164 |
foundNL ifFalse: [ |
|
165 |
"Must be EOF" |
|
166 |
^self |
|
167 |
]. |
|
168 |
char := inStream peek |
|
169 |
]. |
|
170 |
inStream atEnd not and: [char isSeparator] |
|
171 |
] whileTrue: [inStream next] |
|
172 |
||
173 |
"Created: / 3.2.1998 / 17:20:37 / cg" |
|
174 |
"Modified: / 7.9.1998 / 15:49:07 / cg" |
|
175 |
! ! |
|
176 |
||
177 |
!PBMReader methodsFor:'private-writing'! |
|
178 |
||
179 |
writeCommonHeader:format on:aStream |
|
180 |
"common header for P4, P5 and P5 formats" |
|
181 |
||
182 |
aStream nextPutAll:format; cr. |
|
183 |
aStream nextPutAll:'# From Smalltalk/X on '. |
|
184 |
aStream nextPutAll:(Date today printString). |
|
185 |
aStream nextPutAll:' at '; nextPutAll:(Time now printString). |
|
186 |
aStream cr. |
|
187 |
aStream nextPutAll:(width printString); space; nextPutAll:(height printString). |
|
188 |
||
189 |
"Created: / 14.10.1997 / 20:01:05 / cg" |
|
190 |
"Modified: / 1.4.1998 / 14:30:47 / cg" |
|
191 |
! ! |
|
192 |
||
1805 | 193 |
!PBMReader methodsFor:'reading'! |
200 | 194 |
|
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
195 |
fromStream:aStream |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
196 |
"read a Portable bitmap file format as of Jeff Poskanzers Portable Bitmap Package. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
197 |
supported are PBM, PGB and PNM files." |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
198 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
199 |
| pnmType | |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
200 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
201 |
inStream := aStream. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
202 |
inStream text. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
203 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
204 |
inStream next == $P ifFalse:[ |
811
86a93acb3be7
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
205 |
^ self fileFormatError:'not PNM format'. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
206 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
207 |
pnmType := inStream next. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
208 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
209 |
(pnmType == $1) ifTrue: [ |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
210 |
^ self readDepth1AsciiPBMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
211 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
212 |
(pnmType == $3) ifTrue: [ |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
213 |
^ self readDepth24AsciiPBMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
214 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
215 |
(pnmType == $4) ifTrue: [ |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
216 |
^ self readDepth1PBMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
217 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
218 |
(pnmType == $5) ifTrue: [ |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
219 |
^ self readDepth8PGMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
220 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
221 |
(pnmType == $6) ifTrue: [ |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
222 |
^ self readDepth24PPMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
223 |
]. |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
224 |
(pnmType == $7) ifTrue: [ |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
225 |
^ self readDepth8PPMStream |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
226 |
]. |
811
86a93acb3be7
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
227 |
^ self fileFormatError:'No recognized PNM file format'. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
228 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
229 |
" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
230 |
PBMReader fromFile:'bitmaps/testimg.ppm' |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
231 |
PBMReader fromFile:'../../fileIn/bitmaps/keyboard.pbm' |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
232 |
PBMReader fromFile:'/home2/cg/ppm2fli_b1-92/jeff.001' |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
233 |
" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
234 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
235 |
"Created: / 3.2.1998 / 17:25:34 / cg" |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
236 |
"Modified: / 7.9.1998 / 15:44:29 / cg" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
237 |
! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
238 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
239 |
readDepth1AsciiPBMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
240 |
"import portable bitmap ascii (PBM, P1 format); P1 is already read" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
241 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
242 |
|n bits rowIdx dstIdx bytesPerRow char| |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
243 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
244 |
(self readWidthAndHeight) ifFalse:[^ nil]. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
245 |
inStream nextLine "skipThrough: Character cr". |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
246 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
247 |
bytesPerRow := (width + 7) // 8. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
248 |
data := ByteArray new:bytesPerRow * height. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
249 |
rowIdx := 1. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
250 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
251 |
1 to:height do:[:row | |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
252 |
dstIdx := rowIdx. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
253 |
bits := 0. n := 0. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
254 |
1 to:width do:[:col | |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
255 |
char := inStream next. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
256 |
[char notNil and:[char isSeparator]] whileTrue:[ |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
257 |
char := inStream next |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
258 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
259 |
bits := bits bitShift:1. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
260 |
char == $1 ifTrue:[ |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
261 |
bits := bits bitOr:1 |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
262 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
263 |
n := n + 1. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
264 |
n == 8 ifTrue:[ |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
265 |
data at:dstIdx put:bits. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
266 |
dstIdx := dstIdx + 1. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
267 |
bits := 0. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
268 |
n := 0. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
269 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
270 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
271 |
n ~~ 0 ifTrue:[ |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
272 |
data at:dstIdx put:bits. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
273 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
274 |
rowIdx := rowIdx + bytesPerRow |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
275 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
276 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
277 |
photometric := #whiteIs0. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
278 |
samplesPerPixel := 1. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
279 |
bitsPerSample := #(1). |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
280 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
281 |
"Created: / 3.2.1998 / 17:21:22 / cg" |
811
86a93acb3be7
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
282 |
"Modified: / 3.2.1998 / 17:56:32 / cg" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
283 |
! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
284 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
285 |
readDepth1PBMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
286 |
"import portable bitmap (PBM, P4 format); P4 is already read" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
287 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
288 |
|bytesPerRow| |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
289 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
290 |
(self readWidthAndHeight) ifFalse:[^ nil]. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
291 |
inStream nextLine "skipThrough: Character cr". |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
292 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
293 |
bytesPerRow := width // 8. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
294 |
((width \\ 8) ~~ 0) ifTrue:[ |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
295 |
bytesPerRow := bytesPerRow + 1 |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
296 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
297 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
298 |
"/ the rest is the binary image data ... |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
299 |
inStream binary. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
300 |
data := ByteArray uninitializedNew:(bytesPerRow*height). |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
301 |
inStream nextBytes:(data size) into:data. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
302 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
303 |
photometric := #blackIs0. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
304 |
samplesPerPixel := 1. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
305 |
bitsPerSample := #(1). |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
306 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
307 |
"Created: / 3.2.1998 / 17:21:37 / cg" |
811
86a93acb3be7
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
308 |
"Modified: / 3.2.1998 / 17:56:59 / cg" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
309 |
! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
310 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
311 |
readDepth24AsciiPBMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
312 |
"import ascii portable pixmap (PBM, P3 format); P3 is already read" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
313 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
314 |
|nBytes "{Class: SmallInteger }" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
315 |
v "{Class: SmallInteger }" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
316 |
c| |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
317 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
318 |
(self readWidthAndHeightAndMaxVal) ifFalse:[^ nil]. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
319 |
inStream nextLine "skipThrough: Character cr". |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
320 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
321 |
nBytes := width*height*3. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
322 |
data := ByteArray new:nBytes. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
323 |
1 to:nBytes do:[:i | |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
324 |
inStream skipSeparators. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
325 |
v := 0. |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
326 |
c := inStream next. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
327 |
[c isDigit] whileTrue:[ |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
328 |
v := v * 10 + (c digitValue). |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
329 |
c := inStream next. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
330 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
331 |
data at:i put:v |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
332 |
]. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
333 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
334 |
photometric := #rgb. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
335 |
samplesPerPixel := 3. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
336 |
bitsPerSample := #(8 8 8). |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
337 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
338 |
"Created: / 3.2.1998 / 17:21:55 / cg" |
811
86a93acb3be7
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
339 |
"Modified: / 3.2.1998 / 17:57:30 / cg" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
340 |
! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
341 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
342 |
readDepth24PPMStream |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
343 |
"import portable pixmap (PPM, P6 format); P6 is already read" |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
344 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
345 |
(self readWidthAndHeightAndMaxVal) ifFalse:[^ nil]. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
346 |
inStream nextLine "skipThrough: Character cr". |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
347 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
348 |
"/ the rest is the binary image data ... |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
349 |
inStream binary. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
350 |
data := ByteArray uninitializedNew:(width*height*3). |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
351 |
inStream nextBytes:(data size) into:data. |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
352 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
353 |
photometric := #rgb. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
354 |
samplesPerPixel := 3. |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
355 |
bitsPerSample := #(8 8 8). |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
356 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
357 |
"Created: / 3.2.1998 / 17:22:18 / cg" |
811
86a93acb3be7
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
358 |
"Modified: / 3.2.1998 / 17:57:26 / cg" |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
359 |
! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
360 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
361 |
readDepth8PGMStream |
506 | 362 |
"import portable gray map (PGM, P5 format); P5 is already read" |
200 | 363 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
364 |
(self readWidthAndHeightAndMaxVal) ifFalse:[^ nil]. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
365 |
inStream nextLine "skipThrough: Character cr". |
523 | 366 |
|
367 |
"/ the rest is the binary image data ... |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
368 |
inStream binary. |
523 | 369 |
data := ByteArray uninitializedNew:(width*height). |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
370 |
inStream nextBytes:(data size) into:data. |
200 | 371 |
|
372 |
photometric := #blackIs0. |
|
373 |
samplesPerPixel := 1. |
|
374 |
bitsPerSample := #(8). |
|
506 | 375 |
|
811
86a93acb3be7
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
376 |
"Modified: / 3.2.1998 / 17:57:21 / cg" |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
377 |
! |
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
378 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
379 |
readDepth8PPMStream |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
380 |
"import portable pixmap (PPM, P7 format); P7 is already read" |
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
381 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
382 |
| bitsRed bitsGreen bitsBlue| |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
383 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
384 |
inStream skipSeparators. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
385 |
bitsRed := inStream next - $0. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
386 |
bitsGreen := inStream next - $0. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
387 |
bitsBlue := inStream next - $0. |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
388 |
|
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
389 |
(self readWidthAndHeightAndMaxVal) ifFalse:[^ nil]. |
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
390 |
inStream nextLine "skipThrough: Character cr". |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
391 |
|
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
392 |
"/ the rest is the binary image data ... |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
393 |
inStream binary. |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
394 |
data := ByteArray uninitializedNew:(width*height*1). |
1845
9e16152a374f
dimensionReport & refactoring
Claus Gittinger <cg@exept.de>
parents:
1814
diff
changeset
|
395 |
inStream nextBytes:(data size) into:data. |
1064
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
396 |
|
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
397 |
photometric := #rgb. |
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
398 |
samplesPerPixel := 3. |
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
399 |
bitsPerSample := (Array with:bitsRed with:bitsGreen with:bitsBlue). |
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
400 |
|
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
401 |
"Created: / 7.9.1998 / 15:44:05 / cg" |
27f923c3b93d
added P7 format support (8bit rgb).
Claus Gittinger <cg@exept.de>
parents:
884
diff
changeset
|
402 |
"Modified: / 7.9.1998 / 15:50:36 / cg" |
200 | 403 |
! ! |
404 |
||
1805 | 405 |
!PBMReader methodsFor:'writing'! |
2 | 406 |
|
1814
2f204c2a957d
image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents:
1805
diff
changeset
|
407 |
save:image onStream:aStream |
2 | 408 |
"save image as PBM/PGM/PNM file on aFileName" |
409 |
||
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
410 |
|bitsPerPixel| |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
411 |
|
1078
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
412 |
image mask notNil ifTrue:[ |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
413 |
Image informationLostQuerySignal |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
414 |
raiseWith:image |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
415 |
errorString:('PBM format does not support an imageMask'). |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
416 |
]. |
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
417 |
|
1814
2f204c2a957d
image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents:
1805
diff
changeset
|
418 |
outStream := aStream. |
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
419 |
|
2 | 420 |
width := image width. |
421 |
height := image height. |
|
422 |
photometric := image photometric. |
|
423 |
samplesPerPixel := image samplesPerPixel. |
|
424 |
bitsPerSample := image bitsPerSample. |
|
425 |
colorMap := image colorMap. |
|
46 | 426 |
data := image bits. |
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
427 |
bitsPerPixel := image bitsPerPixel. |
2 | 428 |
|
429 |
photometric == #rgb ifTrue:[ |
|
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
430 |
^ self writePNMFileOn:outStream |
2 | 431 |
]. |
432 |
samplesPerPixel == 1 ifTrue:[ |
|
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
433 |
(bitsPerPixel == 1) ifTrue:[ |
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
434 |
^ self writePBMFileOn:outStream |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
435 |
]. |
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
436 |
(bitsPerPixel == 8) ifTrue:[ |
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
437 |
^ self writePGMFileOn:outStream |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
438 |
]. |
2 | 439 |
]. |
1814
2f204c2a957d
image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents:
1805
diff
changeset
|
440 |
|
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
441 |
^ Image cannotRepresentImageSignal |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
442 |
raiseWith:image |
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
443 |
errorString:('PBMReader cannot represent this image'). |
46 | 444 |
|
445 |
" |
|
446 |
|img| |
|
447 |
||
448 |
img := Image fromFile:'bitmaps/SBrowser.xbm'. |
|
449 |
img inspect. |
|
450 |
PBMReader save:img onFile:'test.pbm'. |
|
451 |
img := Image fromFile:'test.pbm'. |
|
452 |
img inspect. |
|
453 |
||
454 |
||
455 |
|img mono| |
|
456 |
||
457 |
img := Image fromFile:'bitmaps/garfield.gif'. |
|
458 |
img inspect. |
|
459 |
mono := img asMonochromeFormOn:Display. |
|
460 |
img := mono asImage. |
|
461 |
img inspect. |
|
462 |
PBMReader save:img onFile:'test.pbm'. |
|
463 |
img := Image fromFile:'test.pbm'. |
|
464 |
img inspect. |
|
465 |
" |
|
461
bacef118f54a
more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
466 |
|
1078
fc33e172bbbc
raise informationLostSignal before attemting to write the file
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
467 |
"Modified: / 30.9.1998 / 23:30:43 / cg" |
21 | 468 |
! |
469 |
||
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
470 |
writePBMFileOn:aStream |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
471 |
"Saves the receivers image on the file fileName in Portable Bitmap format." |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
472 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
473 |
self writeCommonHeader:'P4' on:aStream. |
46 | 474 |
aStream cr. |
475 |
||
476 |
aStream binary. |
|
477 |
photometric == #blackIs0 ifTrue:[ |
|
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
478 |
aStream nextPutAll:data. |
46 | 479 |
] ifFalse:[ |
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
480 |
data invert. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
481 |
aStream nextPutAll:data. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
482 |
data invert. |
46 | 483 |
]. |
484 |
aStream close. |
|
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
485 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
486 |
" |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
487 |
|i i2| |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
488 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
489 |
i := Image fromFile:'bitmaps/SBrowser.xbm'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
490 |
PBMReader save:i onFile:'foo.pbm'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
491 |
i2 := Image fromFile:'foo.pbm'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
492 |
i2 inspect. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
493 |
" |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
494 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
495 |
"Modified: 14.10.1997 / 20:06:49 / cg" |
21 | 496 |
! |
497 |
||
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
498 |
writePGMFileOn:aStream |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
499 |
"Saves the receivers image on the file fileName in Portable Greymap format." |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
500 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
501 |
self writeCommonHeader:'P5' on:aStream. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
502 |
aStream space. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
503 |
aStream nextPutAll:255 printString. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
504 |
aStream cr. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
505 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
506 |
data size ~~ (width * height) ifTrue:[ |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
507 |
"/ self halt:'data size mismatch'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
508 |
]. |
200 | 509 |
|
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
510 |
aStream binary. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
511 |
photometric == #blackIs0 ifTrue:[ |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
512 |
aStream nextPutAll:data. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
513 |
] ifFalse:[ |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
514 |
data invert. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
515 |
aStream nextPutAll:data. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
516 |
data invert. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
517 |
]. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
518 |
aStream close. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
519 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
520 |
" |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
521 |
|i gI i2| |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
522 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
523 |
i := Image fromFile:'bitmaps/gifImages/garfield.gif'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
524 |
gI := i asFloydSteinbergDitheredGrayImageDepth:8. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
525 |
PBMReader save:gI onFile:'foo.pgm'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
526 |
i2 := Image fromFile:'foo.pgm'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
527 |
i2 inspect. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
528 |
" |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
529 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
530 |
"Modified: 14.10.1997 / 20:06:58 / cg" |
200 | 531 |
! |
532 |
||
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
533 |
writePNMFileOn:aStream |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
534 |
"Saves the receivers image on the file fileName in Portable Anymap format." |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
535 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
536 |
self writeCommonHeader:'P6' on:aStream. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
537 |
aStream space. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
538 |
aStream nextPutAll:255 printString. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
539 |
aStream cr. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
540 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
541 |
data size ~~ (width * height * 3) ifTrue:[ |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
542 |
"/ self halt:'data size mismatch'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
543 |
]. |
200 | 544 |
|
709
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
545 |
aStream binary. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
546 |
aStream nextPutAll:data. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
547 |
aStream close. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
548 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
549 |
" |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
550 |
|i i2| |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
551 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
552 |
i := Image fromFile:'bitmaps/granite.tiff'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
553 |
PBMReader save:i onFile:'foo.pnm'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
554 |
i2 := Image fromFile:'foo.pnm'. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
555 |
i2 inspect. |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
556 |
" |
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
557 |
|
813553f7bd20
added write for P4, P5 and P6 formats.
Claus Gittinger <cg@exept.de>
parents:
679
diff
changeset
|
558 |
"Modified: 14.10.1997 / 20:07:08 / cg" |
2 | 559 |
! ! |
560 |
||
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
561 |
!PBMReader class methodsFor:'documentation'! |
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
562 |
|
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
563 |
version |
1848 | 564 |
^ '$Header: /cvs/stx/stx/libview2/PBMReader.st,v 1.42 2003-11-19 15:38:51 cg Exp $' |
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
565 |
! ! |
1745
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
566 |
|
807
855f41b1ec1a
oops - all readers were lost from 1.28 to 1.29
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
567 |
PBMReader initialize! |