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