113
|
1 |
'From Smalltalk/X, Version:2.10.8 on 9-nov-1995 at 17:56:18' !
|
112
|
2 |
|
|
3 |
ImageReader subclass:#BlitImageReader
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Graphics-Images support'
|
|
8 |
!
|
|
9 |
|
|
10 |
!BlitImageReader class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
version
|
|
13 |
"
|
113
|
14 |
$Header: /cvs/stx/stx/libview2/BlitImageReader.st,v 1.2 1995-11-09 16:57:45 cg Exp $
|
112
|
15 |
"
|
|
16 |
|
|
17 |
"Created: 9.11.1995 / 17:08:06 / cg"
|
|
18 |
!
|
|
19 |
|
|
20 |
documentation
|
|
21 |
"
|
|
22 |
A q&d hack to read 48x48x1 Blit images (faces)
|
|
23 |
"
|
|
24 |
|
|
25 |
"Created: 9.11.1995 / 17:08:06 / cg"
|
|
26 |
"Modified: 9.11.1995 / 17:08:26 / cg"
|
|
27 |
!
|
|
28 |
|
|
29 |
examples
|
|
30 |
"
|
|
31 |
Image fromFile:'.../.../48x48x1'
|
|
32 |
"
|
|
33 |
|
|
34 |
"Created: 9.11.1995 / 17:08:06 / cg"
|
|
35 |
"Modified: 9.11.1995 / 17:08:42 / cg"
|
|
36 |
!
|
|
37 |
|
|
38 |
history
|
|
39 |
|
|
40 |
"Created: 9.11.1995 / 17:08:06 / cg"
|
|
41 |
"Modified: 9.11.1995 / 17:08:06 / cg"
|
|
42 |
! !
|
|
43 |
|
|
44 |
!BlitImageReader class methodsFor:'initialization'!
|
|
45 |
|
|
46 |
initialize
|
|
47 |
Image fileFormats at:'48x48x1' put:self.
|
|
48 |
|
|
49 |
"
|
|
50 |
BlitImageReader initialize
|
|
51 |
"
|
|
52 |
|
|
53 |
"Created: 9.11.1995 / 17:05:04 / cg"
|
|
54 |
"Modified: 9.11.1995 / 17:06:28 / cg"
|
|
55 |
! !
|
|
56 |
|
113
|
57 |
!BlitImageReader class methodsFor:'special formats'!
|
|
58 |
|
|
59 |
fromCompressedString:aString
|
|
60 |
"since I am not willing to include the uncompface stuff into ST/X,
|
|
61 |
open a pipe to the uncompressor.
|
|
62 |
If you dont have compface/uncompface, get it from your nearest ftp server."
|
|
63 |
|
|
64 |
|f s img|
|
|
65 |
|
|
66 |
f := Filename newTemporary.
|
|
67 |
s := f writeStream.
|
|
68 |
s nextPutAll:aString.
|
|
69 |
s close.
|
|
70 |
|
|
71 |
s := PipeStream readingFrom:('uncompface ' , f name).
|
|
72 |
s isNil ifTrue:[
|
|
73 |
'BLITIMGREADER: no uncompface utility.' errorPrintNL.
|
|
74 |
^ nil
|
|
75 |
].
|
|
76 |
|
|
77 |
img := self fromStream:s.
|
|
78 |
s close.
|
|
79 |
^ img
|
|
80 |
|
|
81 |
"
|
|
82 |
|s|
|
|
83 |
|
|
84 |
s := '
|
|
85 |
Iqsa(US9p?)Y^W
|
|
86 |
+6Ff[Z]<t?\A!!eaL''DG{20*#{C1;''Ct&}L}B^/1(aYI@hP)4!!<}7D=2gm
|
|
87 |
8!!$T`8QNfK<te\20%A\`wm*wa2' , Character doubleQuote asString , '^Up*Qs' , Character doubleQuote asString ,
|
|
88 |
'X}KeV*3XeB2te&sKp*t`N;^BDh[6=K{ZBE=O>rM' , Character doubleQuote asString , 'uFE)
|
|
89 |
lFDjag1e]\/#2'.
|
|
90 |
BlitImageReader fromCompressedString:s
|
|
91 |
"
|
|
92 |
|
|
93 |
"Created: 9.11.1995 / 17:55:19 / cg"
|
|
94 |
"Modified: 9.11.1995 / 17:56:07 / cg"
|
|
95 |
! !
|
|
96 |
|
112
|
97 |
!BlitImageReader class methodsFor:'testing'!
|
|
98 |
|
|
99 |
isValidImageFile:aFileName
|
|
100 |
"return true, if aFileName contains a GIF image"
|
|
101 |
|
|
102 |
^ aFileName = '48x48x1'
|
|
103 |
|
|
104 |
"Created: 9.11.1995 / 17:04:29 / cg"
|
|
105 |
! !
|
|
106 |
|
|
107 |
!BlitImageReader methodsFor:'reading'!
|
|
108 |
|
|
109 |
fromStream:aStream
|
|
110 |
|line
|
|
111 |
dstIndex "{ Class: SmallInteger }"
|
|
112 |
bytesPerRow
|
|
113 |
s words nm|
|
|
114 |
|
113
|
115 |
width := height := 48.
|
|
116 |
bytesPerRow := width // 8.
|
112
|
117 |
|
|
118 |
data := ByteArray new:(bytesPerRow * height).
|
|
119 |
dstIndex := 1.
|
|
120 |
|
|
121 |
[aStream atEnd] whileFalse:[
|
113
|
122 |
line := aStream nextLine.
|
|
123 |
line notNil ifTrue:[
|
|
124 |
words := (line asCollectionOfSubstringsSeparatedBy:$,) asOrderedCollection.
|
|
125 |
words last isEmpty ifTrue:[
|
|
126 |
words removeLast
|
|
127 |
].
|
|
128 |
words do:[:w |
|
|
129 |
|s bits|
|
112
|
130 |
|
113
|
131 |
s := w readStream.
|
|
132 |
s skip:2.
|
|
133 |
bits := Integer readFrom:s radix:16 onError:0.
|
|
134 |
data at:dstIndex put:(bits bitShift:-8).
|
|
135 |
data at:dstIndex+1 put:(bits bitAnd:16rFF).
|
|
136 |
dstIndex := dstIndex + 2
|
|
137 |
]
|
|
138 |
]
|
112
|
139 |
].
|
|
140 |
|
|
141 |
|
|
142 |
photometric := #whiteIs0.
|
|
143 |
samplesPerPixel := 1.
|
|
144 |
bitsPerSample := #(1)
|
|
145 |
|
|
146 |
"
|
|
147 |
BlitImageReader fromFile:'/tmp/faces/facedir/facedir/misc./acsnet/48x48x1'
|
|
148 |
"
|
|
149 |
|
|
150 |
"Created: 9.11.1995 / 17:03:04 / cg"
|
|
151 |
! !
|
|
152 |
|
|
153 |
BlitImageReader initialize!
|