author | Claus Gittinger <cg@exept.de> |
Wed, 22 Nov 1995 13:06:56 +0100 | |
changeset 118 | 7f0415d8308d |
parent 114 | e577a2f332d0 |
child 133 | 57daa569a22b |
permissions | -rw-r--r-- |
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
1 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
3 |
All Rights Reserved |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
4 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
5 |
This software is furnished under a license and may be used |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
10 |
hereby transferred. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
11 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
12 |
|
113 | 13 |
'From Smalltalk/X, Version:2.10.8 on 9-nov-1995 at 17:56:18' ! |
112 | 14 |
|
15 |
ImageReader subclass:#BlitImageReader |
|
16 |
instanceVariableNames:'' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Graphics-Images support' |
|
20 |
! |
|
21 |
||
22 |
!BlitImageReader class methodsFor:'documentation'! |
|
23 |
||
24 |
version |
|
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
25 |
^ '$Header: /cvs/stx/stx/libview2/BlitImageReader.st,v 1.4 1995-11-22 12:06:56 cg Exp $' |
112 | 26 |
! |
27 |
||
28 |
documentation |
|
29 |
" |
|
30 |
A q&d hack to read 48x48x1 Blit images (faces) |
|
31 |
" |
|
32 |
! |
|
33 |
||
34 |
examples |
|
35 |
" |
|
36 |
Image fromFile:'.../.../48x48x1' |
|
37 |
" |
|
38 |
! |
|
39 |
||
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
40 |
copyright |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
41 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
42 |
COPYRIGHT (c) 1995 by Claus Gittinger |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
43 |
All Rights Reserved |
112 | 44 |
|
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
45 |
This software is furnished under a license and may be used |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
46 |
only in accordance with the terms of that license and with the |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
47 |
inclusion of the above copyright notice. This software may not |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
48 |
be provided or otherwise made available to, or used by, any |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
49 |
other person. No title to or ownership of the software is |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
50 |
hereby transferred. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
51 |
" |
112 | 52 |
! ! |
53 |
||
54 |
!BlitImageReader class methodsFor:'initialization'! |
|
55 |
||
56 |
initialize |
|
57 |
Image fileFormats at:'48x48x1' put:self. |
|
58 |
||
59 |
" |
|
60 |
BlitImageReader initialize |
|
61 |
" |
|
62 |
||
63 |
"Created: 9.11.1995 / 17:05:04 / cg" |
|
64 |
"Modified: 9.11.1995 / 17:06:28 / cg" |
|
65 |
! ! |
|
66 |
||
113 | 67 |
!BlitImageReader class methodsFor:'special formats'! |
68 |
||
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
69 |
uncompressString:aString |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
70 |
"given a compressed string (as present in mail-headers), |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
71 |
return a string in 48x48x1 BlitImage fromat. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
72 |
Since I am not willing to port/include the uncompface stuff into ST/X, |
113 | 73 |
open a pipe to the uncompressor. |
74 |
If you dont have compface/uncompface, get it from your nearest ftp server." |
|
75 |
||
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
76 |
|f s str| |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
77 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
78 |
f := Filename newTemporary. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
79 |
s := f writeStream. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
80 |
s nextPutAll:aString. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
81 |
s close. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
82 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
83 |
s := PipeStream readingFrom:('uncompface ' , f name). |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
84 |
s isNil ifTrue:[ |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
85 |
'BLITIMGREADER: no uncompface utility.' errorPrintNL. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
86 |
f delete. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
87 |
^ nil |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
88 |
]. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
89 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
90 |
str := s contents asString. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
91 |
s close. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
92 |
f delete. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
93 |
^ str |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
94 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
95 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
96 |
|s| |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
97 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
98 |
s := ' |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
99 |
Iqsa(US9p?)Y^W |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
100 |
+6Ff[Z]<t?\A!eaL''DG{20*#{C1;''Ct&}L}B^/1(aYI@hP)4!<}7D=2gm |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
101 |
8!$T`8QNfK<te\20%A\`wm*wa2' , Character doubleQuote asString , '^Up*Qs' , Character doubleQuote asString , |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
102 |
'X}KeV*3XeB2te&sKp*t`N;^BDh[6=K{ZBE=O>rM' , Character doubleQuote asString , 'uFE) |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
103 |
lFDjag1e]\/#2'. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
104 |
BlitImageReader uncompressString:s |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
105 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
106 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
107 |
"Created: 9.11.1995 / 17:55:19 / cg" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
108 |
"Modified: 21.11.1995 / 19:28:41 / cg" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
109 |
! |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
110 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
111 |
fromCompressedString:aString |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
112 |
"given a compressed image string (such as present in mail headers), |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
113 |
return a Depth1Image for it. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
114 |
Since I am not willing to port/include the uncompface stuff into ST/X, |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
115 |
open a pipe to the uncompressor. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
116 |
If you dont have compface/uncompface, get it from your nearest ftp server." |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
117 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
118 |
|f s img| |
113 | 119 |
|f s img| |
120 |
||
121 |
f := Filename newTemporary. |
|
122 |
s := f writeStream. |
|
123 |
s nextPutAll:aString. |
|
124 |
s close. |
|
125 |
||
126 |
s := PipeStream readingFrom:('uncompface ' , f name). |
|
127 |
s isNil ifTrue:[ |
|
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
113
diff
changeset
|
128 |
'BLITIMGREADER: no uncompface utility.' errorPrintNL. |
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
129 |
f delete. |
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
113
diff
changeset
|
130 |
^ nil |
113 | 131 |
]. |
132 |
||
133 |
img := self fromStream:s. |
|
134 |
s close. |
|
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
135 |
f delete. |
113 | 136 |
^ img |
137 |
||
138 |
" |
|
139 |
|s| |
|
140 |
||
141 |
s := ' |
|
142 |
Iqsa(US9p?)Y^W |
|
143 |
+6Ff[Z]<t?\A!!eaL''DG{20*#{C1;''Ct&}L}B^/1(aYI@hP)4!!<}7D=2gm |
|
144 |
8!!$T`8QNfK<te\20%A\`wm*wa2' , Character doubleQuote asString , '^Up*Qs' , Character doubleQuote asString , |
|
145 |
'X}KeV*3XeB2te&sKp*t`N;^BDh[6=K{ZBE=O>rM' , Character doubleQuote asString , 'uFE) |
|
146 |
lFDjag1e]\/#2'. |
|
147 |
BlitImageReader fromCompressedString:s |
|
148 |
" |
|
149 |
||
150 |
"Created: 9.11.1995 / 17:55:19 / cg" |
|
151 |
"Modified: 9.11.1995 / 17:56:07 / cg" |
|
152 |
! ! |
|
153 |
||
112 | 154 |
!BlitImageReader class methodsFor:'testing'! |
155 |
||
156 |
isValidImageFile:aFileName |
|
157 |
"return true, if aFileName contains a GIF image" |
|
158 |
||
159 |
^ aFileName = '48x48x1' |
|
160 |
||
161 |
"Created: 9.11.1995 / 17:04:29 / cg" |
|
162 |
! ! |
|
163 |
||
164 |
!BlitImageReader methodsFor:'reading'! |
|
165 |
||
166 |
fromStream:aStream |
|
167 |
|line |
|
168 |
dstIndex "{ Class: SmallInteger }" |
|
169 |
bytesPerRow |
|
170 |
s words nm| |
|
171 |
||
113 | 172 |
width := height := 48. |
173 |
bytesPerRow := width // 8. |
|
112 | 174 |
|
175 |
data := ByteArray new:(bytesPerRow * height). |
|
176 |
dstIndex := 1. |
|
177 |
||
178 |
[aStream atEnd] whileFalse:[ |
|
113 | 179 |
line := aStream nextLine. |
180 |
line notNil ifTrue:[ |
|
181 |
words := (line asCollectionOfSubstringsSeparatedBy:$,) asOrderedCollection. |
|
182 |
words last isEmpty ifTrue:[ |
|
183 |
words removeLast |
|
184 |
]. |
|
185 |
words do:[:w | |
|
186 |
|s bits| |
|
112 | 187 |
|
113 | 188 |
s := w readStream. |
189 |
s skip:2. |
|
190 |
bits := Integer readFrom:s radix:16 onError:0. |
|
191 |
data at:dstIndex put:(bits bitShift:-8). |
|
192 |
data at:dstIndex+1 put:(bits bitAnd:16rFF). |
|
193 |
dstIndex := dstIndex + 2 |
|
194 |
] |
|
195 |
] |
|
112 | 196 |
]. |
197 |
||
198 |
||
199 |
photometric := #whiteIs0. |
|
200 |
samplesPerPixel := 1. |
|
201 |
bitsPerSample := #(1) |
|
202 |
||
203 |
" |
|
204 |
BlitImageReader fromFile:'/tmp/faces/facedir/facedir/misc./acsnet/48x48x1' |
|
205 |
" |
|
206 |
||
207 |
"Created: 9.11.1995 / 17:03:04 / cg" |
|
208 |
! ! |
|
209 |
||
210 |
BlitImageReader initialize! |