author | Claus Gittinger <cg@exept.de> |
Tue, 23 Apr 1996 12:24:18 +0200 | |
changeset 196 | a3153c2b1d27 |
parent 120 | 719d6c8c3b39 |
child 197 | 50812e81d86f |
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 |
" |
|
38 |
this class knows how to read face files. |
|
120 | 39 |
(this format is used for people's faces - which can be optained from some |
21 | 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:] |
66 |
BlitImageReader FaceReader JPEGReader PBMReader PCXReader |
|
67 |
ST80FormReader SunRasterReader TIFFReader WindowsIconReader |
|
68 |
XBMreader XPMReader XWDReader |
|
21 | 69 |
" |
70 |
! ! |
|
5 | 71 |
|
26 | 72 |
!FaceReader class methodsFor:'initialization'! |
73 |
||
74 |
initialize |
|
196 | 75 |
"install myself in the Image classes fileFormat table" |
76 |
||
26 | 77 |
Image fileFormats at:'.face' put:self. |
196 | 78 |
|
79 |
"Modified: 23.4.1996 / 12:23:15 / cg" |
|
26 | 80 |
! ! |
81 |
||
0 | 82 |
!FaceReader methodsFor:'reading from file'! |
83 |
||
43 | 84 |
fromStream:aStream |
196 | 85 |
"read an image in my format from aStream" |
86 |
||
0 | 87 |
|line |
88 |
dstIndex "{ Class: SmallInteger }" |
|
89 |
bytesPerRow |
|
90 |
lo "{ Class: SmallInteger }" |
|
91 |
hi "{ Class: SmallInteger }" |
|
92 |
val "{ Class: SmallInteger }" |
|
93 |
inHeader s depth| |
|
94 |
||
43 | 95 |
inStream := aStream. |
0 | 96 |
|
43 | 97 |
line := aStream nextLine. |
0 | 98 |
line isNil ifTrue:[ |
196 | 99 |
^ nil |
0 | 100 |
]. |
101 |
||
102 |
inHeader := true. |
|
103 |
[inHeader] whileTrue:[ |
|
196 | 104 |
(line startsWith:'Image:') ifTrue:[ |
105 |
s := ReadStream on:line. |
|
106 |
s position:7. |
|
107 |
width := Number readFrom:s. |
|
108 |
height := Number readFrom:s. |
|
109 |
depth := Number readFrom:s. |
|
110 |
inHeader := false. |
|
111 |
]. |
|
112 |
line := aStream nextLine |
|
0 | 113 |
]. |
114 |
||
115 |
depth == 8 ifFalse:[ |
|
196 | 116 |
self error:'only depth 8 supported' |
0 | 117 |
]. |
118 |
||
119 |
[line isEmpty] whileTrue:[ |
|
196 | 120 |
line := aStream nextLine. |
0 | 121 |
]. |
122 |
||
123 |
bytesPerRow := width * depth // 8. |
|
124 |
((width * depth \\ 8) ~~ 0) ifTrue:[ |
|
196 | 125 |
bytesPerRow := bytesPerRow + 1 |
0 | 126 |
]. |
127 |
||
1 | 128 |
data := ByteArray uninitializedNew:(bytesPerRow * height). |
0 | 129 |
dstIndex := data size. |
130 |
||
131 |
[line notNil] whileTrue:[ |
|
196 | 132 |
1 to:(line size) by:2 do:[:cI | |
133 |
hi := (line at:cI) digitValue. |
|
134 |
lo := (line at:(cI + 1)) digitValue. |
|
135 |
val := (hi bitShift:4) bitOr:lo. |
|
136 |
data at:dstIndex put:val. |
|
137 |
dstIndex := dstIndex - 1 |
|
138 |
]. |
|
139 |
line := aStream nextLine |
|
0 | 140 |
]. |
120 | 141 |
photometric := #blackIs0. |
0 | 142 |
samplesPerPixel := 1. |
143 |
bitsPerSample := #(8) |
|
144 |
||
120 | 145 |
" |
146 |
FaceReader fromFile:'../goodies/faces/next.com/steve.face' |
|
147 |
" |
|
0 | 148 |
"this is NOT steve jobs :-)" |
196 | 149 |
|
150 |
"Modified: 23.4.1996 / 12:23:38 / cg" |
|
0 | 151 |
! ! |
196 | 152 |
|
153 |
!FaceReader class methodsFor:'documentation'! |
|
154 |
||
155 |
version |
|
156 |
^ '$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.15 1996-04-23 10:24:18 cg Exp $' |
|
157 |
! ! |
|
158 |
FaceReader initialize! |