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