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