BlitImageReader.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Apr 1996 18:32:07 +0200
changeset 221 ea942fe5dc04
parent 210 5405de794686
child 234 b6352d13e792
permissions -rw-r--r--
documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     1
"
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     3
	      All Rights Reserved
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     4
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     5
 This software is furnished under a license and may be used
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     6
 only in accordance with the terms of that license and with the
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
     9
 other person.  No title to or ownership of the software is
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    10
 hereby transferred.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    11
"
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    12
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
ImageReader subclass:#BlitImageReader
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    14
	instanceVariableNames:''
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    15
	classVariableNames:''
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    16
	poolDictionaries:''
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    17
	category:'Graphics-Images support'
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!BlitImageReader class methodsFor:'documentation'!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    22
copyright 
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    23
"
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    25
	      All Rights Reserved
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    27
 This software is furnished under a license and may be used
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    28
 only in accordance with the terms of that license and with the
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    30
 be provided or otherwise made available to, or used by, any
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    31
 other person.  No title to or ownership of the software is
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    32
 hereby transferred.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    33
"
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    34
!
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    35
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    36
documentation
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    37
"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    38
    A q&d hack to read 48x48x1 Blit images (faces)
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    39
    A variation of this format is also used to pass face-icons in mail headers
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    40
    (X-face: header line).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    41
    To support those, images can also be read from a string which is
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    42
    encoded in that format (see: #fromCompressedString:).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    43
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    44
    [See also:]
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    45
        GIFReader FaceReader JPEGReader PBMReader PCXReader 
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    46
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader 
209
840ddcf12904 commentary
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
    47
        XBMReader XPMReader XWDReader 
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    48
"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    49
!
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    50
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    51
examples
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    52
"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    53
    Image fromFile:'.../.../48x48x1'
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    54
"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
! !
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
!BlitImageReader class methodsFor:'initialization'!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
initialize
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    60
    "install myself in the Image classes fileFormat table
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    61
     for files named `48x48x1' (funny)."
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    62
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    Image fileFormats at:'48x48x1'  put:self.
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    "
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
     BlitImageReader initialize
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    "
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    69
    "Modified: 23.4.1996 / 12:47:48 / cg"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
! !
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
113
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    72
!BlitImageReader class methodsFor:'special formats'!
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    73
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    74
fromCompressedString:aString
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    75
    "given a compressed image string (such as present in mail headers),
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    76
     return a Depth1Image for it.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    77
     Since I am not willing to port/include the uncompface stuff into ST/X,
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    78
     open a pipe to the uncompressor.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    79
     If you dont have compface/uncompface, get it from your nearest ftp server."
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    80
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    81
    |f s img|
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    82
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    83
    f := Filename newTemporary.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    84
    s := f writeStream.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    85
    s nextPutAll:aString.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    86
    s close.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    87
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    88
    s := PipeStream readingFrom:('uncompface ' , f name).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    89
    s isNil ifTrue:[
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    90
	'BLITIMGREADER: no uncompface utility.' errorPrintNL.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    91
	f delete.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    92
	^ nil
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    93
    ].
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    94
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    95
    img := self fromStream:s.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    96
    s close.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    97
    f delete.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    98
    ^ img
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    99
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   100
    "   
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   101
     |s|
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   102
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   103
     s := '
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   104
Iqsa(US9p?)Y^W
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   105
+6Ff[Z]<t?\A!!eaL''DG{20*#{C1;''Ct&}L}B^/1(aYI@hP)4!!<}7D=2gm
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   106
8!!$T`8QNfK<te\20%A\`wm*wa2' , Character doubleQuote asString , '^Up*Qs' , Character doubleQuote asString ,
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   107
'X}KeV*3XeB2te&sKp*t`N;^BDh[6=K{ZBE=O>rM' , Character doubleQuote asString , 'uFE)
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   108
lFDjag1e]\/#2'.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   109
    BlitImageReader fromCompressedString:s
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   110
    "
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   111
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   112
    "Created: 9.11.1995 / 17:55:19 / cg"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   113
    "Modified: 9.11.1995 / 17:56:07 / cg"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   114
!
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   115
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   116
uncompressString:aString
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   117
    "given a compressed string (as present in mail-headers),
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   118
     return a string in 48x48x1 BlitImage fromat.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   119
     Since I am not willing to port/include the uncompface stuff into ST/X,
113
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   120
     open a pipe to the uncompressor.
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   121
     If you dont have compface/uncompface, get it from your nearest ftp server."
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   122
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   123
    |f s str|
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   124
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   125
    f := Filename newTemporary.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   126
    s := f writeStream.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   127
    s nextPutAll:aString.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   128
    s close.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   129
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   130
    s := PipeStream readingFrom:('uncompface ' , f name).
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   131
    s isNil ifTrue:[
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   132
	'BLITIMGREADER: no uncompface utility.' errorPrintNL.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   133
	f delete.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   134
	^ nil
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   135
    ].
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   136
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   137
    str := s contents asString.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   138
    s close.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   139
    f delete.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   140
    ^ str
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   141
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   142
    "   
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   143
     |s|
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   144
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   145
     s := '
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   146
Iqsa(US9p?)Y^W
141
977cb52010f9 double exclas in the comment
Claus Gittinger <cg@exept.de>
parents: 133
diff changeset
   147
+6Ff[Z]<t?\A!!eaL''DG{20*#{C1;''Ct&}L}B^/1(aYI@hP)4!!<}7D=2gm
977cb52010f9 double exclas in the comment
Claus Gittinger <cg@exept.de>
parents: 133
diff changeset
   148
8!!$T`8QNfK<te\20%A\`wm*wa2' , Character doubleQuote asString , '^Up*Qs' , Character doubleQuote asString ,
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   149
'X}KeV*3XeB2te&sKp*t`N;^BDh[6=K{ZBE=O>rM' , Character doubleQuote asString , 'uFE)
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   150
lFDjag1e]\/#2'.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   151
    BlitImageReader uncompressString:s
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   152
    "
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   153
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   154
    "Created: 9.11.1995 / 17:55:19 / cg"
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   155
    "Modified: 21.11.1995 / 19:28:41 / cg"
113
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   156
! !
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   157
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
!BlitImageReader class methodsFor:'testing'!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
isValidImageFile:aFileName
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   161
    "return true, if aFileName contains a BlitImage image"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    ^ aFileName = '48x48x1'
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    "Created: 9.11.1995 / 17:04:29 / cg"
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   166
    "Modified: 23.4.1996 / 12:48:01 / cg"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
! !
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
!BlitImageReader methodsFor:'reading'!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
fromStream:aStream
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   172
    "read an image in my format from aStream"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   173
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    |line 
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
     dstIndex "{ Class: SmallInteger }"
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
     bytesPerRow
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
     s words nm|
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
113
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   179
    width := height := 48.
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   180
    bytesPerRow := width // 8.
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    data := ByteArray new:(bytesPerRow * height).
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    dstIndex := 1.
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    [aStream atEnd] whileFalse:[
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   186
        line := aStream nextLine.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   187
        line notNil ifTrue:[
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   188
            words := (line asCollectionOfSubstringsSeparatedBy:$,) asOrderedCollection.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   189
            words last isEmpty ifTrue:[
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   190
                words removeLast
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   191
            ].
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   192
            words do:[:w |
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   193
                |s bits|
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   195
                s := w readStream.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   196
                s skip:2.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   197
                bits := Integer readFrom:s radix:16 onError:0. 
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   198
                data at:dstIndex put:(bits bitShift:-8).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   199
                data at:dstIndex+1 put:(bits bitAnd:16rFF).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   200
                dstIndex := dstIndex + 2
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   201
            ]
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   202
        ]
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    ].
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    photometric := #whiteIs0.
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    samplesPerPixel := 1.
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    bitsPerSample := #(1)
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
     BlitImageReader fromFile:'/tmp/faces/facedir/facedir/misc./acsnet/48x48x1'
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    "
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    "Created: 9.11.1995 / 17:03:04 / cg"
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   215
    "Modified: 23.4.1996 / 12:48:15 / cg"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
! !
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   218
!BlitImageReader class methodsFor:'documentation'!
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   219
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   220
version
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   221
    ^ '$Header: /cvs/stx/stx/libview2/BlitImageReader.st,v 1.9 1996-04-23 11:05:45 cg Exp $'
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   222
! !
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
BlitImageReader initialize!