author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 07 Jun 2019 19:57:30 +0100 | |
branch | jv |
changeset 4278 | 8cc5f9eafef8 |
parent 3855 | 1db7742d33ad |
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 |
" |
|
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1846
diff
changeset
|
12 |
"{ Package: 'stx:libview2' }" |
0 | 13 |
|
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1846
diff
changeset
|
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. |
42 |
This format is used for people's faces - which can be obtained from some |
|
43 |
ftp-servers, to improve mail- and/or newsreaders :-). |
|
120 | 44 |
Other than above, that format is not used often. |
45 |
||
46 |
The file format is (ascii): |
|
196 | 47 |
... |
48 |
FirstName: ... |
|
49 |
LastName: ... |
|
50 |
E-mail: ... |
|
51 |
PicData: ... |
|
52 |
Image: <width> <height> <depth> |
|
53 |
||
54 |
bits; encoded in uppercase hex ascii; 2 chars/pixel |
|
55 |
pixel values are greyscale-value; 0..255 |
|
56 |
||
57 |
Only 8-bit greyscale is supported |
|
58 |
- I have never encountered any other face-file-format. |
|
120 | 59 |
|
196 | 60 |
Only file reading is supported. |
61 |
||
120 | 62 |
|
196 | 63 |
Notice: |
64 |
Face files come in two formats: the first is the one implemented here, |
|
65 |
the other is the blitImage file format, which only supports 48x48x1 images. |
|
66 |
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
|
67 |
|
196 | 68 |
[See also:] |
234 | 69 |
Image Form Icon |
197 | 70 |
BlitImageReader GIFReader JPEGReader PBMReader PCXReader |
210 | 71 |
ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader |
209 | 72 |
XBMReader XPMReader XWDReader |
21 | 73 |
" |
74 |
! ! |
|
5 | 75 |
|
26 | 76 |
!FaceReader class methodsFor:'initialization'! |
77 |
||
78 |
initialize |
|
198 | 79 |
"install myself in the Image classes fileFormat table |
80 |
for the `.face' extension." |
|
196 | 81 |
|
647 | 82 |
MIMETypes defineImageType:nil suffix:'face' reader:self |
196 | 83 |
|
398 | 84 |
"Modified: 1.2.1997 / 15:01:25 / cg" |
26 | 85 |
! ! |
86 |
||
1805 | 87 |
!FaceReader methodsFor:'reading'! |
0 | 88 |
|
1739 | 89 |
readImage |
90 |
"read an image in my format from my inStream" |
|
196 | 91 |
|
0 | 92 |
|line |
93 |
dstIndex "{ Class: SmallInteger }" |
|
94 |
bytesPerRow |
|
95 |
lo "{ Class: SmallInteger }" |
|
96 |
hi "{ Class: SmallInteger }" |
|
97 |
val "{ Class: SmallInteger }" |
|
98 |
inHeader s depth| |
|
99 |
||
1739 | 100 |
line := inStream nextLine. |
0 | 101 |
line isNil ifTrue:[ |
808
495535230e80
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
102 |
^ self fileFormatError:'short read'. |
0 | 103 |
]. |
104 |
||
105 |
inHeader := true. |
|
106 |
[inHeader] whileTrue:[ |
|
196 | 107 |
(line startsWith:'Image:') ifTrue:[ |
108 |
s := ReadStream on:line. |
|
1753 | 109 |
s skip:6. |
196 | 110 |
width := Number readFrom:s. |
111 |
height := Number readFrom:s. |
|
112 |
depth := Number readFrom:s. |
|
113 |
inHeader := false. |
|
114 |
]. |
|
1739 | 115 |
line := inStream nextLine |
0 | 116 |
]. |
117 |
||
118 |
depth == 8 ifFalse:[ |
|
808
495535230e80
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
119 |
^ self fileFormatError:'only depth 8 supported'. |
0 | 120 |
]. |
121 |
||
1846 | 122 |
self reportDimension. |
123 |
||
0 | 124 |
[line isEmpty] whileTrue:[ |
1739 | 125 |
line := inStream nextLine. |
0 | 126 |
]. |
127 |
||
128 |
bytesPerRow := width * depth // 8. |
|
129 |
((width * depth \\ 8) ~~ 0) ifTrue:[ |
|
196 | 130 |
bytesPerRow := bytesPerRow + 1 |
0 | 131 |
]. |
132 |
||
1 | 133 |
data := ByteArray uninitializedNew:(bytesPerRow * height). |
0 | 134 |
dstIndex := data size. |
135 |
||
136 |
[line notNil] whileTrue:[ |
|
196 | 137 |
1 to:(line size) by:2 do:[:cI | |
138 |
hi := (line at:cI) digitValue. |
|
139 |
lo := (line at:(cI + 1)) digitValue. |
|
140 |
val := (hi bitShift:4) bitOr:lo. |
|
141 |
data at:dstIndex put:val. |
|
142 |
dstIndex := dstIndex - 1 |
|
143 |
]. |
|
1739 | 144 |
line := inStream nextLine |
0 | 145 |
]. |
120 | 146 |
photometric := #blackIs0. |
0 | 147 |
samplesPerPixel := 1. |
148 |
bitsPerSample := #(8) |
|
149 |
||
120 | 150 |
" |
151 |
FaceReader fromFile:'../goodies/faces/next.com/steve.face' |
|
152 |
" |
|
0 | 153 |
"this is NOT steve jobs :-)" |
196 | 154 |
|
808
495535230e80
use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
155 |
"Modified: / 3.2.1998 / 17:50:52 / cg" |
0 | 156 |
! ! |
196 | 157 |
|
158 |
!FaceReader class methodsFor:'documentation'! |
|
159 |
||
160 |
version |
|
1846 | 161 |
^ '$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.30 2003-11-19 15:28:06 cg Exp $' |
196 | 162 |
! ! |
1739 | 163 |
|
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1846
diff
changeset
|
164 |
|
196 | 165 |
FaceReader initialize! |