BlitImageReader.st
author Claus Gittinger <cg@exept.de>
Sat, 01 Feb 1997 15:07:04 +0100
changeset 398 aef700d15416
parent 259 62b1bbafd9ba
child 647 6f26c76aa0c9
permissions -rw-r--r--
new suffix-table
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:''
259
62b1bbafd9ba category change
Claus Gittinger <cg@exept.de>
parents: 234
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:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    45
        Image Form Icon
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    46
        GIFReader FaceReader JPEGReader PBMReader PCXReader 
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    47
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader 
209
840ddcf12904 commentary
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
    48
        XBMReader XPMReader XWDReader 
206
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
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    52
examples
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    53
"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    54
    Image fromFile:'.../.../48x48x1'
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    55
"
112
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
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!BlitImageReader class methodsFor:'initialization'!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
initialize
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    61
    "install myself in the Image classes fileFormat table
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    62
     for files named `48x48x1' (funny)."
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    63
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    64
    Image addReader:self suffix:'48x48x1'
112
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
    "
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
     BlitImageReader initialize
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    "
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    70
    "Modified: 1.2.1997 / 15:01:08 / cg"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
! !
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
113
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    73
!BlitImageReader class methodsFor:'special formats'!
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    74
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    75
fromCompressedString:aString
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    76
    "given a compressed image string (such as present in mail headers),
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    77
     return a Depth1Image for it.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    78
     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
    79
     open a pipe to the uncompressor.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    80
     If you dont have compface/uncompface, get it from your nearest ftp server."
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    81
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    82
    |f s img|
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    83
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    84
    f := Filename newTemporary.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    85
    s := f writeStream.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    86
    s nextPutAll:aString.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    87
    s close.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    88
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    89
    s := PipeStream readingFrom:('uncompface ' , f name).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    90
    s isNil ifTrue:[
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    91
	'BLITIMGREADER: no uncompface utility.' errorPrintNL.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    92
	f delete.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    93
	^ nil
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    94
    ].
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    95
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    96
    img := self fromStream:s.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    97
    s close.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    98
    f delete.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
    99
    ^ img
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   100
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   101
    "   
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   102
     |s|
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   103
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   104
     s := '
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   105
Iqsa(US9p?)Y^W
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   106
+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
   107
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
   108
'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
   109
lFDjag1e]\/#2'.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   110
    BlitImageReader fromCompressedString:s
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   111
    "
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   112
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   113
    "Created: 9.11.1995 / 17:55:19 / cg"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   114
    "Modified: 9.11.1995 / 17:56:07 / cg"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   115
!
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   116
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   117
uncompressString:aString
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   118
    "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
   119
     return a string in 48x48x1 BlitImage fromat.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   120
     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
   121
     open a pipe to the uncompressor.
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   122
     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
   123
118
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   124
    |f s str|
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   125
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   126
    f := Filename newTemporary.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   127
    s := f writeStream.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   128
    s nextPutAll:aString.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   129
    s close.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   130
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   131
    s := PipeStream readingFrom:('uncompface ' , f name).
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   132
    s isNil ifTrue:[
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   133
	'BLITIMGREADER: no uncompface utility.' errorPrintNL.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   134
	f delete.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   135
	^ nil
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
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   138
    str := s contents asString.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   139
    s close.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   140
    f delete.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   141
    ^ str
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
    "   
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   144
     |s|
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   145
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   146
     s := '
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   147
Iqsa(US9p?)Y^W
141
977cb52010f9 double exclas in the comment
Claus Gittinger <cg@exept.de>
parents: 133
diff changeset
   148
+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
   149
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
   150
'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
   151
lFDjag1e]\/#2'.
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   152
    BlitImageReader uncompressString:s
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
7f0415d8308d new method to uncompress blit-formatted strings
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   155
    "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
   156
    "Modified: 21.11.1995 / 19:28:41 / cg"
113
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   157
! !
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   158
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
!BlitImageReader class methodsFor:'testing'!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
isValidImageFile:aFileName
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   162
    "return true, if aFileName contains a BlitImage image"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    ^ aFileName = '48x48x1'
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    "Created: 9.11.1995 / 17:04:29 / cg"
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   167
    "Modified: 23.4.1996 / 12:48:01 / cg"
112
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
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
!BlitImageReader methodsFor:'reading'!
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
fromStream:aStream
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   173
    "read an image in my format from aStream"
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   174
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    |line 
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
     dstIndex "{ Class: SmallInteger }"
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
     bytesPerRow
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
     s words nm|
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
113
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   180
    width := height := 48.
465cc202f0fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   181
    bytesPerRow := width // 8.
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    data := ByteArray new:(bytesPerRow * height).
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    dstIndex := 1.
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    [aStream atEnd] whileFalse:[
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   187
        line := aStream nextLine.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   188
        line notNil ifTrue:[
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   189
            words := (line asCollectionOfSubstringsSeparatedBy:$,) asOrderedCollection.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   190
            words last isEmpty ifTrue:[
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   191
                words removeLast
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   192
            ].
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   193
            words do:[:w |
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   194
                |s bits|
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   196
                s := w readStream.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   197
                s skip:2.
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   198
                bits := Integer readFrom:s radix:16 onError:0. 
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   199
                data at:dstIndex put:(bits bitShift:-8).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   200
                data at:dstIndex+1 put:(bits bitAnd:16rFF).
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   201
                dstIndex := dstIndex + 2
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   202
            ]
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   203
        ]
112
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
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    photometric := #whiteIs0.
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    samplesPerPixel := 1.
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    bitsPerSample := #(1)
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
    "
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
     BlitImageReader fromFile:'/tmp/faces/facedir/facedir/misc./acsnet/48x48x1'
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
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
    "Created: 9.11.1995 / 17:03:04 / cg"
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   216
    "Modified: 23.4.1996 / 12:48:15 / cg"
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
! !
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   219
!BlitImageReader class methodsFor:'documentation'!
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   220
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   221
version
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   222
    ^ '$Header: /cvs/stx/stx/libview2/BlitImageReader.st,v 1.12 1997-02-01 14:05:39 cg Exp $'
206
975f42e01bb1 commentary
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   223
! !
112
9b59ed94db13 q&d hack (for Blit faces)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
BlitImageReader initialize!