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