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
|
26
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
32
|
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 |
version
|
|
37 |
"
|
99
|
38 |
$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.12 1995-08-30 17:53:50 claus Exp $
|
21
|
39 |
"
|
|
40 |
!
|
5
|
41 |
|
21
|
42 |
documentation
|
|
43 |
"
|
|
44 |
this class knows how to read face files.
|
|
45 |
(this format is used for peoples faces - which can be optained from some
|
|
46 |
ftp-servers, to improve mail- and/or newsreaders :-)
|
|
47 |
"
|
|
48 |
! !
|
5
|
49 |
|
26
|
50 |
!FaceReader class methodsFor:'initialization'!
|
|
51 |
|
|
52 |
initialize
|
|
53 |
Image fileFormats at:'.face' put:self.
|
|
54 |
! !
|
|
55 |
|
0
|
56 |
!FaceReader methodsFor:'reading from file'!
|
|
57 |
|
43
|
58 |
fromStream:aStream
|
0
|
59 |
|line
|
|
60 |
dstIndex "{ Class: SmallInteger }"
|
|
61 |
bytesPerRow
|
|
62 |
lo "{ Class: SmallInteger }"
|
|
63 |
hi "{ Class: SmallInteger }"
|
|
64 |
val "{ Class: SmallInteger }"
|
|
65 |
inHeader s depth|
|
|
66 |
|
43
|
67 |
inStream := aStream.
|
0
|
68 |
|
43
|
69 |
line := aStream nextLine.
|
0
|
70 |
line isNil ifTrue:[
|
26
|
71 |
^ nil
|
0
|
72 |
].
|
|
73 |
|
|
74 |
inHeader := true.
|
|
75 |
[inHeader] whileTrue:[
|
26
|
76 |
(line startsWith:'Image:') ifTrue:[
|
|
77 |
s := ReadStream on:line.
|
|
78 |
s position:7.
|
|
79 |
width := Number readFrom:s.
|
|
80 |
height := Number readFrom:s.
|
|
81 |
depth := Number readFrom:s.
|
|
82 |
inHeader := false.
|
|
83 |
].
|
43
|
84 |
line := aStream nextLine
|
0
|
85 |
].
|
|
86 |
|
|
87 |
depth == 8 ifFalse:[
|
26
|
88 |
self error:'only depth 8 supported'
|
0
|
89 |
].
|
|
90 |
|
|
91 |
[line isEmpty] whileTrue:[
|
43
|
92 |
line := aStream nextLine.
|
0
|
93 |
].
|
|
94 |
|
|
95 |
bytesPerRow := width * depth // 8.
|
|
96 |
((width * depth \\ 8) ~~ 0) ifTrue:[
|
26
|
97 |
bytesPerRow := bytesPerRow + 1
|
0
|
98 |
].
|
|
99 |
|
1
|
100 |
data := ByteArray uninitializedNew:(bytesPerRow * height).
|
0
|
101 |
dstIndex := data size.
|
|
102 |
|
|
103 |
[line notNil] whileTrue:[
|
26
|
104 |
1 to:(line size) by:2 do:[:cI |
|
|
105 |
hi := (line at:cI) digitValue.
|
|
106 |
lo := (line at:(cI + 1)) digitValue.
|
|
107 |
val := (hi bitShift:4) bitOr:lo.
|
|
108 |
data at:dstIndex put:val.
|
|
109 |
dstIndex := dstIndex - 1
|
|
110 |
].
|
43
|
111 |
line := aStream nextLine
|
0
|
112 |
].
|
|
113 |
photometric := #whiteIs0.
|
|
114 |
samplesPerPixel := 1.
|
|
115 |
bitsPerSample := #(8)
|
|
116 |
|
|
117 |
"FaceReader fromFile:'../goodies/faces/next.com/steve.face'"
|
|
118 |
"this is NOT steve jobs :-)"
|
|
119 |
! !
|