author | Stefan Vogel <sv@exept.de> |
Mon, 13 Mar 2017 09:54:33 +0100 | |
changeset 3941 | dd9237d3a727 |
parent 3922 | a82b5a12bf52 |
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 |
" |
3922 | 12 |
"{ Package: 'stx:libview2' }" |
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
13 |
|
3922 | 14 |
"{ NameSpace: Smalltalk }" |
1740 | 15 |
|
112 | 16 |
ImageReader subclass:#BlitImageReader |
206 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
1745
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1740
diff
changeset
|
20 |
category:'Graphics-Images-Readers' |
112 | 21 |
! |
22 |
||
23 |
!BlitImageReader class methodsFor:'documentation'! |
|
24 |
||
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
25 |
copyright |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
26 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
28 |
All Rights Reserved |
112 | 29 |
|
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
hereby transferred. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
36 |
" |
206 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
A q&d hack to read 48x48x1 Blit images (faces) |
|
42 |
A variation of this format is also used to pass face-icons in mail headers |
|
43 |
(X-face: header line). |
|
44 |
To support those, images can also be read from a string which is |
|
45 |
encoded in that format (see: #fromCompressedString:). |
|
46 |
||
3922 | 47 |
These images were quite common in the early 90's to annotate emails and news articles. |
48 |
The format is now completely forgotten and of no real use (except, maybe for historicans). |
|
49 |
||
206 | 50 |
[See also:] |
234 | 51 |
Image Form Icon |
206 | 52 |
GIFReader FaceReader JPEGReader PBMReader PCXReader |
210 | 53 |
ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader |
209 | 54 |
XBMReader XPMReader XWDReader |
206 | 55 |
" |
56 |
! |
|
57 |
||
58 |
examples |
|
59 |
" |
|
60 |
Image fromFile:'.../.../48x48x1' |
|
61 |
" |
|
112 | 62 |
! ! |
63 |
||
64 |
!BlitImageReader class methodsFor:'initialization'! |
|
65 |
||
66 |
initialize |
|
206 | 67 |
"install myself in the Image classes fileFormat table |
68 |
for files named `48x48x1' (funny)." |
|
69 |
||
1740 | 70 |
MIMETypes defineImageType:nil "'image/x-blitImage'" suffix:'48x48x1' reader:self |
112 | 71 |
|
72 |
" |
|
73 |
BlitImageReader initialize |
|
74 |
" |
|
75 |
||
398 | 76 |
"Modified: 1.2.1997 / 15:01:08 / cg" |
112 | 77 |
! ! |
78 |
||
113 | 79 |
!BlitImageReader class methodsFor:'special formats'! |
80 |
||
206 | 81 |
fromCompressedString:aString |
82 |
"given a compressed image string (such as present in mail headers), |
|
83 |
return a Depth1Image for it. |
|
84 |
Since I am not willing to port/include the uncompface stuff into ST/X, |
|
85 |
open a pipe to the uncompressor. |
|
86 |
If you dont have compface/uncompface, get it from your nearest ftp server." |
|
87 |
||
1740 | 88 |
|s| |
206 | 89 |
|
1740 | 90 |
s := self uncompressString:aString. |
91 |
^ self fromStream:(s readStream). |
|
206 | 92 |
|
93 |
" |
|
94 |
|s| |
|
95 |
||
96 |
s := ' |
|
97 |
Iqsa(US9p?)Y^W |
|
98 |
+6Ff[Z]<t?\A!!eaL''DG{20*#{C1;''Ct&}L}B^/1(aYI@hP)4!!<}7D=2gm |
|
99 |
8!!$T`8QNfK<te\20%A\`wm*wa2' , Character doubleQuote asString , '^Up*Qs' , Character doubleQuote asString , |
|
100 |
'X}KeV*3XeB2te&sKp*t`N;^BDh[6=K{ZBE=O>rM' , Character doubleQuote asString , 'uFE) |
|
101 |
lFDjag1e]\/#2'. |
|
102 |
BlitImageReader fromCompressedString:s |
|
103 |
" |
|
104 |
||
105 |
"Created: 9.11.1995 / 17:55:19 / cg" |
|
106 |
"Modified: 9.11.1995 / 17:56:07 / cg" |
|
107 |
! |
|
108 |
||
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
109 |
uncompressString:aString |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
110 |
"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
|
111 |
return a string in 48x48x1 BlitImage fromat. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
112 |
Since I am not willing to port/include the uncompface stuff into ST/X, |
113 | 113 |
open a pipe to the uncompressor. |
114 |
If you dont have compface/uncompface, get it from your nearest ftp server." |
|
115 |
||
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
116 |
|f s str| |
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 := Filename newTemporary. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
119 |
s := f writeStream. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
120 |
s nextPutAll:aString. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
121 |
s close. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
122 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
123 |
s := PipeStream readingFrom:('uncompface ' , f name). |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
124 |
s isNil ifTrue:[ |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
125 |
'BLITIMGREADER: no uncompface utility.' errorPrintNL. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
126 |
f delete. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
127 |
^ nil |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
128 |
]. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
129 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
130 |
str := s contents asString. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
131 |
s close. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
132 |
f delete. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
133 |
^ str |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
134 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
135 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
136 |
|s| |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
137 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
138 |
s := ' |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
139 |
Iqsa(US9p?)Y^W |
141 | 140 |
+6Ff[Z]<t?\A!!eaL''DG{20*#{C1;''Ct&}L}B^/1(aYI@hP)4!!<}7D=2gm |
141 |
8!!$T`8QNfK<te\20%A\`wm*wa2' , Character doubleQuote asString , '^Up*Qs' , Character doubleQuote asString , |
|
118
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
142 |
'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
|
143 |
lFDjag1e]\/#2'. |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
144 |
BlitImageReader uncompressString:s |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
145 |
" |
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
146 |
|
7f0415d8308d
new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents:
114
diff
changeset
|
147 |
"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
|
148 |
"Modified: 21.11.1995 / 19:28:41 / cg" |
113 | 149 |
! ! |
150 |
||
112 | 151 |
!BlitImageReader class methodsFor:'testing'! |
152 |
||
153 |
isValidImageFile:aFileName |
|
206 | 154 |
"return true, if aFileName contains a BlitImage image" |
112 | 155 |
|
156 |
^ aFileName = '48x48x1' |
|
157 |
||
158 |
"Created: 9.11.1995 / 17:04:29 / cg" |
|
206 | 159 |
"Modified: 23.4.1996 / 12:48:01 / cg" |
112 | 160 |
! ! |
161 |
||
162 |
!BlitImageReader methodsFor:'reading'! |
|
163 |
||
164 |
fromStream:aStream |
|
206 | 165 |
"read an image in my format from aStream" |
166 |
||
112 | 167 |
|line |
168 |
dstIndex "{ Class: SmallInteger }" |
|
1846 | 169 |
bytesPerRow words| |
112 | 170 |
|
113 | 171 |
width := height := 48. |
1846 | 172 |
self reportDimension. |
113 | 173 |
bytesPerRow := width // 8. |
112 | 174 |
|
175 |
data := ByteArray new:(bytesPerRow * height). |
|
176 |
dstIndex := 1. |
|
177 |
||
178 |
[aStream atEnd] whileFalse:[ |
|
206 | 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 |
|
206 | 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" |
|
206 | 208 |
"Modified: 23.4.1996 / 12:48:15 / cg" |
112 | 209 |
! ! |
210 |
||
206 | 211 |
!BlitImageReader class methodsFor:'documentation'! |
212 |
||
213 |
version |
|
3922 | 214 |
^ '$Header$' |
206 | 215 |
! ! |
1740 | 216 |
|
3922 | 217 |
|
112 | 218 |
BlitImageReader initialize! |