author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 18:32:07 +0200 | |
changeset 221 | ea942fe5dc04 |
parent 218 | 96e8e87e5dc8 |
child 234 | b6352d13e792 |
permissions | -rw-r--r-- |
5 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
26 | 3 |
All Rights Reserved |
5 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
0 | 12 |
|
13 |
ImageReader subclass:#FaceReader |
|
196 | 14 |
instanceVariableNames:'' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Graphics-Images support' |
|
0 | 18 |
! |
19 |
||
21 | 20 |
!FaceReader class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
26 | 25 |
All Rights Reserved |
5 | 26 |
|
21 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
5 | 35 |
|
21 | 36 |
documentation |
37 |
" |
|
218 | 38 |
This class knows how to read face files. |
39 |
This format is used for people's faces - which can be obtained from some |
|
40 |
ftp-servers, to improve mail- and/or newsreaders :-). |
|
120 | 41 |
Other than above, that format is not used often. |
42 |
||
43 |
The file format is (ascii): |
|
196 | 44 |
... |
45 |
FirstName: ... |
|
46 |
LastName: ... |
|
47 |
E-mail: ... |
|
48 |
PicData: ... |
|
49 |
Image: <width> <height> <depth> |
|
50 |
||
51 |
bits; encoded in uppercase hex ascii; 2 chars/pixel |
|
52 |
pixel values are greyscale-value; 0..255 |
|
53 |
||
54 |
Only 8-bit greyscale is supported |
|
55 |
- I have never encountered any other face-file-format. |
|
120 | 56 |
|
196 | 57 |
Only file reading is supported. |
58 |
||
120 | 59 |
|
196 | 60 |
Notice: |
61 |
Face files come in two formats: the first is the one implemented here, |
|
62 |
the other is the blitImage file format, which only supports 48x48x1 images. |
|
63 |
The latter is supported by the BlitImageReader class. |
|
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
99
diff
changeset
|
64 |
|
196 | 65 |
[See also:] |
197 | 66 |
BlitImageReader GIFReader JPEGReader PBMReader PCXReader |
210 | 67 |
ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader |
209 | 68 |
XBMReader XPMReader XWDReader |
21 | 69 |
" |
70 |
! ! |
|
5 | 71 |
|
26 | 72 |
!FaceReader class methodsFor:'initialization'! |
73 |
||
74 |
initialize |
|
198 | 75 |
"install myself in the Image classes fileFormat table |
76 |
for the `.face' extension." |
|
196 | 77 |
|
26 | 78 |
Image fileFormats at:'.face' put:self. |
196 | 79 |
|
198 | 80 |
"Modified: 23.4.1996 / 12:27:35 / cg" |
26 | 81 |
! ! |
82 |
||
0 | 83 |
!FaceReader methodsFor:'reading from file'! |
84 |
||
43 | 85 |
fromStream:aStream |
196 | 86 |
"read an image in my format from aStream" |
87 |
||
0 | 88 |
|line |
89 |
dstIndex "{ Class: SmallInteger }" |
|
90 |
bytesPerRow |
|
91 |
lo "{ Class: SmallInteger }" |
|
92 |
hi "{ Class: SmallInteger }" |
|
93 |
val "{ Class: SmallInteger }" |
|
94 |
inHeader s depth| |
|
95 |
||
43 | 96 |
inStream := aStream. |
0 | 97 |
|
43 | 98 |
line := aStream nextLine. |
0 | 99 |
line isNil ifTrue:[ |
196 | 100 |
^ nil |
0 | 101 |
]. |
102 |
||
103 |
inHeader := true. |
|
104 |
[inHeader] whileTrue:[ |
|
196 | 105 |
(line startsWith:'Image:') ifTrue:[ |
106 |
s := ReadStream on:line. |
|
107 |
s position:7. |
|
108 |
width := Number readFrom:s. |
|
109 |
height := Number readFrom:s. |
|
110 |
depth := Number readFrom:s. |
|
111 |
inHeader := false. |
|
112 |
]. |
|
113 |
line := aStream nextLine |
|
0 | 114 |
]. |
115 |
||
116 |
depth == 8 ifFalse:[ |
|
196 | 117 |
self error:'only depth 8 supported' |
0 | 118 |
]. |
119 |
||
120 |
[line isEmpty] whileTrue:[ |
|
196 | 121 |
line := aStream nextLine. |
0 | 122 |
]. |
123 |
||
124 |
bytesPerRow := width * depth // 8. |
|
125 |
((width * depth \\ 8) ~~ 0) ifTrue:[ |
|
196 | 126 |
bytesPerRow := bytesPerRow + 1 |
0 | 127 |
]. |
128 |
||
1 | 129 |
data := ByteArray uninitializedNew:(bytesPerRow * height). |
0 | 130 |
dstIndex := data size. |
131 |
||
132 |
[line notNil] whileTrue:[ |
|
196 | 133 |
1 to:(line size) by:2 do:[:cI | |
134 |
hi := (line at:cI) digitValue. |
|
135 |
lo := (line at:(cI + 1)) digitValue. |
|
136 |
val := (hi bitShift:4) bitOr:lo. |
|
137 |
data at:dstIndex put:val. |
|
138 |
dstIndex := dstIndex - 1 |
|
139 |
]. |
|
140 |
line := aStream nextLine |
|
0 | 141 |
]. |
120 | 142 |
photometric := #blackIs0. |
0 | 143 |
samplesPerPixel := 1. |
144 |
bitsPerSample := #(8) |
|
145 |
||
120 | 146 |
" |
147 |
FaceReader fromFile:'../goodies/faces/next.com/steve.face' |
|
148 |
" |
|
0 | 149 |
"this is NOT steve jobs :-)" |
196 | 150 |
|
151 |
"Modified: 23.4.1996 / 12:23:38 / cg" |
|
0 | 152 |
! ! |
196 | 153 |
|
154 |
!FaceReader class methodsFor:'documentation'! |
|
155 |
||
156 |
version |
|
218 | 157 |
^ '$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.20 1996-04-25 16:09:57 stefan Exp $' |
196 | 158 |
! ! |
159 |
FaceReader initialize! |