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