XPMReader.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Jan 2020 17:47:56 +0100
changeset 4431 732c2cd831b8
parent 4376 12b16a7174e9
permissions -rw-r--r--
#OTHER by cg fix: if moving over an item within the same view, possibly suppress already forked and scheduled helptext (eg. when moving over close-icon in a tabList, moving within the same tab label, but away from the close icon, the tooltip was shown erronously in the previous version)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4376
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
     1
"{ Encoding: utf8 }"
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
     2
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
     3
"
24b4aff428c0 Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1994 by Claus Gittinger
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
     5
	      All Rights Reserved
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
     6
24b4aff428c0 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
24b4aff428c0 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
24b4aff428c0 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    13
"
1400
8a7b55b08bf3 category change
Claus Gittinger <cg@exept.de>
parents: 1012
diff changeset
    14
"{ Package: 'stx:libview2' }"
8a7b55b08bf3 category change
Claus Gittinger <cg@exept.de>
parents: 1012
diff changeset
    15
3688
10011de73077 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
    16
"{ NameSpace: Smalltalk }"
10011de73077 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
    17
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    18
ImageReader subclass:#XPMReader
1814
2f204c2a957d image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    19
	instanceVariableNames:'charsPerPixel maskPixelValue characterTranslation imageName'
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    20
	classVariableNames:''
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    21
	poolDictionaries:''
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1743
diff changeset
    22
	category:'Graphics-Images-Readers'
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    23
!
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    24
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    25
!XPMReader class methodsFor:'documentation'!
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    26
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    27
copyright
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    28
"
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    29
 COPYRIGHT (c) 1994 by Claus Gittinger
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
    30
	      All Rights Reserved
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    31
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    32
 This software is furnished under a license and may be used
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    37
 hereby transferred.
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    38
"
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    39
!
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    40
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    41
documentation
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    42
"
1812
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    43
    This class provides methods for loading x-pixmap-file (xpm) images.
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    44
1812
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    45
    These images are used (in X) for palette images 
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    46
    (see ctwm or hp-vue for a lot of them).
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    47
    The format is actually a piece of C-code, which can be compiled by the C-compiler
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    48
    into a constant image data structure.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    49
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    50
    The code here is a hack - it may not work for all images 
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    51
    (it works for the testfiles I got here).
24
6bc436eb4c4a *** empty log message ***
claus
parents: 22
diff changeset
    52
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    53
    Limitations: 
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    54
        only reads the full-color specification, ignoring monochrome
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    55
        and greyscale info.
24
6bc436eb4c4a *** empty log message ***
claus
parents: 22
diff changeset
    56
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    57
        Can only handle single-character index.
24
6bc436eb4c4a *** empty log message ***
claus
parents: 22
diff changeset
    58
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    59
        Only understands single-word color names (i.e. names with spaces 
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    60
        are not supported)
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    61
1812
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    62
        Image writing is only supported for images with less than about 200
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    63
        colors (single byte encoding). 
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    64
        If present, the mask must be a single bit mask (i.e. no alpha channel).
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    65
        Due to the algorithm, writing may be slow for big images
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    66
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    67
    Suggestions: adapt & use the XPM library here.
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    68
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    69
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    70
    [See also:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    71
        Image Form Icon
4100
e39b98dbbf85 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3960
diff changeset
    72
        BlitImageReader FaceReader GIFReader JPEGReader MacOSXIconReader
e39b98dbbf85 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3960
diff changeset
    73
        PBMReader PCXReader PNGReader
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
    74
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader 
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    75
        XBMReader XWDReader 
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
    76
"
1812
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    77
!
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    78
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    79
examples
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    80
"
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    81
  Reading from a file:
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    82
                                                                        [exBegin]
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    83
    |image|
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    84
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    85
    image := Image fromFile:('../../goodies/bitmaps/xpmBitmaps/INFO.xpm').
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    86
    image inspect
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    87
                                                                        [exEnd]
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    88
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    89
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    90
  Saving to a file:
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    91
                                                                        [exBegin]
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    92
    |image|
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    93
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    94
    image := Image fromScreen:(0@0 corner:30@30).
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    95
    image usedColors size > 256 ifTrue:[
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    96
        image := image asDitheredImageUsing:(Color standardDitherColorsForDepth8) depth:8.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    97
    ].
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    98
    XPMReader save:image onFile:'/tmp/test.xpm'.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
    99
    '/tmp/test.xpm' asFilename contents asString inspect
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   100
                                                                        [exEnd]
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   101
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   102
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   103
  Or directly into a stream:
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   104
                                                                        [exBegin]
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   105
    |image stream|
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   106
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   107
    image := Image fromScreen:(0@0 corner:30@30).
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   108
    image usedColors size > 256 ifTrue:[
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   109
        image := image asDitheredImageUsing:(Color standardDitherColorsForDepth8) depth:8.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   110
    ].
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   111
    stream := WriteStream on:(String new).
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   112
    XPMReader save:image onStream:stream.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   113
    stream contents inspect
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   114
                                                                        [exEnd]
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   115
"
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   116
! !
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   117
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   118
!XPMReader class methodsFor:'initialization'!
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   119
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   120
initialize
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   121
    "tell Image-class, that a new fileReader is present
400
b40294e3fee0 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   122
     for the '.xpm' and '.pm' extensions."
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   123
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   124
    MIMETypes defineImageType:'image/x-xpixmap' suffix:'xpm' reader:self.
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   125
    MIMETypes defineImageType:nil               suffix:'pm'  reader:self.
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 384
diff changeset
   126
400
b40294e3fee0 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   127
    "Modified: 1.2.1997 / 15:10:29 / cg"
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   128
! !
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   129
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   130
!XPMReader class methodsFor:'testing'!
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   131
460
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   132
canRepresent:anImage
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   133
    "return true, if anImage can be represented in my file format.
461
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   134
     Currently only images with less than 80 colors are supported."
460
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   135
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   136
    anImage depth <= 6 ifTrue:[^ true].
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   137
    anImage photometric == #palette ifTrue:[
1907
67dd6f3420b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1882
diff changeset
   138
        anImage colorMap size < 256 ifTrue:[^ true].
460
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   139
    ].
3419
2e30918fce3a class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   140
    (anImage usedColorsMax:256) notNil ifTrue:[^ true].
2e30918fce3a class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   141
    ('XPMReader [info]: too many colors in image (only up to 256 supported).') infoPrintCR.
1495
100e4e782f71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   142
    ^ false
460
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   143
461
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   144
    "Modified: 27.2.1997 / 12:40:22 / cg"
460
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   145
!
2c2215c50c28 added #canRepresent:
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   146
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   147
isValidImageFile:aFileName
4376
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   148
    "return true, if aFileName contains an x-pixmap-file image.
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   149
     Does not really validate - just looks for the '/* XPM' string"
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   150
4376
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   151
    |ok line inStream |
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   152
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   153
    inStream := self streamReadingFile:aFileName.
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   154
    inStream isNil ifTrue:[^ false].
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   155
4376
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   156
    ok := false.
550
254480517864 handle long line read error.
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   157
    Stream readErrorSignal handle:[:ex |
254480517864 handle long line read error.
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   158
    ] do:[
1510
4e0133eec046 care for invalid format (long line)
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
   159
        Stream lineTooLongErrorSignal handle:[:ex |
2803
b1f0edb9c078 changed: #isValidImageFile:
Claus Gittinger <cg@exept.de>
parents: 2030
diff changeset
   160
            Transcript showCR:'XPMReader [info]: long line'.
1510
4e0133eec046 care for invalid format (long line)
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
   161
        ] do:[
4e0133eec046 care for invalid format (long line)
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
   162
            line := inStream nextLine.
4376
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   163
            line notNil ifTrue:[
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   164
                ok := (line startsWith:'/* XPM')
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   165
            ]
1510
4e0133eec046 care for invalid format (long line)
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
   166
        ]
550
254480517864 handle long line read error.
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   167
    ].
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   168
    inStream close.
4376
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   169
    ^ ok
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   170
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   171
    "
562
921472d151d9 handle commented lines (in colorSpec)
Claus Gittinger <cg@exept.de>
parents: 560
diff changeset
   172
     XPMReader isValidImageFile:'fooBar'    
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   173
     XPMReader isValidImageFile:'../../goodies/bitmaps/xpmBitmaps/device_images/ljet.xpm'      
4376
12b16a7174e9 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4359
diff changeset
   174
     XPMReader isValidImageFile:'../../goodies/bitmaps/bitmaps/gifImages/garfield.gif' 
550
254480517864 handle long line read error.
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   175
    "
254480517864 handle long line read error.
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   176
562
921472d151d9 handle commented lines (in colorSpec)
Claus Gittinger <cg@exept.de>
parents: 560
diff changeset
   177
    "Modified: 24.4.1997 / 20:29:40 / cg"
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   178
! !
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   179
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   180
!XPMReader methodsFor:'private-reading'!
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   181
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   182
colorNameFrom:aStream
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   183
    "read either a color-name or value specified in X-notation
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   184
     (#rrggbb where rr, gg and bb are 2-digit hex numbers)"
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   185
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   186
    |s|
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   187
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   188
    aStream peek == $# ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   189
	aStream next.
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   190
	s := '#'.
24
6bc436eb4c4a *** empty log message ***
claus
parents: 22
diff changeset
   191
    ] ifFalse:[
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   192
	s := ''.
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   193
    ].
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   194
    [aStream peek isLetterOrDigit] whileTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   195
	s := s copyWith:aStream next
24
6bc436eb4c4a *** empty log message ***
claus
parents: 22
diff changeset
   196
    ].
6bc436eb4c4a *** empty log message ***
claus
parents: 22
diff changeset
   197
    ^ s
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   198
!
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   199
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   200
readColorMap:colorMapSize
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   201
    |redMap greenMap blueMap s key lineDone state
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   202
     symbolicName monoName greyName grey4Name colorName|
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   203
107
Claus Gittinger <cg@exept.de>
parents: 99
diff changeset
   204
    redMap := ByteArray new:colorMapSize.
Claus Gittinger <cg@exept.de>
parents: 99
diff changeset
   205
    greenMap := ByteArray new:colorMapSize.
Claus Gittinger <cg@exept.de>
parents: 99
diff changeset
   206
    blueMap := ByteArray new:colorMapSize.
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   207
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   208
    1 to:colorMapSize do:[:colorIndex |
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   209
        |index line color t word|
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   210
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   211
        line := inStream nextLine.
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   212
        [line notNil and:[line startsWith:'/*']] whileTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   213
            [line notNil and:[(line endsWith:'*/') not]] whileTrue:[
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   214
                line := inStream nextLine.
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   215
            ].
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   216
            line := inStream nextLine.
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   217
        ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   218
        line notNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   219
            line := line withoutSeparators
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   220
        ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   221
        (line notNil and:[line startsWith:'"']) ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   222
            ^ self fileFormatError:'format error (expected color spec)'.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   223
        ].
24
6bc436eb4c4a *** empty log message ***
claus
parents: 22
diff changeset
   224
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   225
        s := ReadStream on:line.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   226
        s next. "skip quote"
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   227
        charsPerPixel ~~ 1 ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   228
            key := s next:charsPerPixel.
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   229
            characterTranslation at:key put:colorIndex - 1.
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   230
        ] ifFalse:[
1952
5009754ae556 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 1907
diff changeset
   231
            index := s next codePoint.
1737
a1ed08195ee7 refactorings
Claus Gittinger <cg@exept.de>
parents: 1710
diff changeset
   232
            characterTranslation at:index put:colorIndex - 1.
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   233
        ].
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   234
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   235
        lineDone := false.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   236
        state := nil.
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   237
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   238
        [lineDone] whileFalse:[
4359
1a689188f9aa #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4100
diff changeset
   239
            s skipSeparators == $# ifTrue:[
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   240
                word := self colorNameFrom:s
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   241
            ] ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   242
                word := s nextAlphaNumericWord.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   243
            ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   244
            word isNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   245
                lineDone := true
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   246
            ] ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   247
                word = 's' ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   248
                    "/ symbolic name ...
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   249
                    state := $s. symbolicName := ''.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   250
                ] ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   251
                    word = 'm' ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   252
                        "/ monochrome data
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   253
                        state := $m. monoName := ''.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   254
                    ] ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   255
                        word = 'g' ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   256
                            "/ grey data
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   257
                            state := $g. greyName := ''.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   258
                        ] ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   259
                            word = 'g4' ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   260
                                "/ grey data
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   261
                                state := $G. grey4Name := ''.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   262
                            ] ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   263
                                word = 'c' ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   264
                                    "/ color data
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   265
                                    state := $c. colorName := ''.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   266
                                ] ifFalse:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   267
                                    "/ append to name
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   268
                                    state isNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   269
                                        ^ self fileFormatError:('format error got: ' 
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   270
                                                                , word printString 
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   271
                                                                , ' (expected ''c'',''m'',''g'' or ''s'')').
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   272
                                    ].
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   273
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   274
                                    state == $m ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   275
                                        monoName := monoName , ' ' , word.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   276
                                    ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   277
                                    state == $g ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   278
                                        greyName := greyName , ' ' , word.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   279
                                    ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   280
                                    state == $G ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   281
                                        grey4Name := grey4Name , ' ' , word.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   282
                                    ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   283
                                    state == $c ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   284
                                        colorName := colorName , ' ' , word.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   285
                                    ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   286
                                    state == $s ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   287
                                        symbolicName := symbolicName , ' ' , word.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   288
                                    ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   289
                                    (word startsWith:'#') ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   290
                                        state := nil.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   291
                                    ]
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   292
                                ]
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   293
                            ]
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   294
                        ]
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   295
                    ]
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   296
                ]
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   297
            ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   298
        ].
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   299
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   300
        colorName notNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   301
            colorName := colorName withoutSeparators
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   302
        ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   303
        monoName notNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   304
            monoName := monoName withoutSeparators
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   305
        ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   306
        greyName notNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   307
            greyName := greyName withoutSeparators
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   308
        ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   309
        grey4Name notNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   310
            grey4Name := grey4Name withoutSeparators
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   311
        ].
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   312
        symbolicName notNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   313
            symbolicName := symbolicName withoutSeparators
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   314
        ].
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   315
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   316
        "/
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   317
        "/ for now - ignore everything, except
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   318
        "/ colorName (if there is one)
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   319
        "/
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   320
        colorName isNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   321
            colorName := greyName.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   322
            colorName isNil ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   323
                colorName := monoName.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   324
            ]
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   325
        ].
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   326
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   327
        (colorName sameAs: 'none') ifTrue:[
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   328
            color := Color noColor. "/ white
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   329
            redMap at:colorIndex put:0.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   330
            greenMap at:colorIndex put:0.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   331
            blueMap at:colorIndex put:0.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   332
            maskPixelValue := colorIndex-1.
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   333
        ] ifFalse:[
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1743
diff changeset
   334
            color := Color name:colorName ifIllegal:(Color black).
1403
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   335
            redMap at:colorIndex put:(color red asFloat * 255.0 // 100).
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   336
            greenMap at:colorIndex put:(color green asFloat * 255.0 // 100).
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   337
            blueMap at:colorIndex put:(color blue asFloat * 255.0 // 100).
94f9ec117aa5 tuned image reading with 2-char color encoding
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
   338
        ].
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   339
    ].
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1743
diff changeset
   340
1759
f52382e5a9b8 slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   341
    colorMap := MappedPalette redVector:redMap greenVector:greenMap blueVector:blueMap.
4359
1a689188f9aa #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4100
diff changeset
   342
1a689188f9aa #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4100
diff changeset
   343
    "Modified: / 28-09-2019 / 15:29:19 / Stefan Vogel"
22
24b4aff428c0 Initial revision
claus
parents:
diff changeset
   344
! !
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   345
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   346
!XPMReader methodsFor:'private-writing'!
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   347
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   348
colorNameOf:aColor
3886
48e95f2d273d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3688
diff changeset
   349
    "generate a name for a color. If it's a standard color,
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   350
     return its name; otherwise return the hex representation."
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   351
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   352
    #(white black red green blue
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   353
      yellow magenta cyan orange) do:[:aStandardColorName |
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   354
        aColor = (Color name:aStandardColorName) ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   355
            ^ aStandardColorName.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   356
        ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   357
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   358
    ^ '#' 
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   359
     , (aColor redByte hexPrintString:2)
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   360
     , (aColor greenByte hexPrintString:2)
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   361
     , (aColor blueByte hexPrintString:2)
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   362
3886
48e95f2d273d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3688
diff changeset
   363
    "Created: / 27-02-1997 / 11:48:40 / cg"
48e95f2d273d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3688
diff changeset
   364
    "Modified: / 06-06-1998 / 20:58:49 / cg"
48e95f2d273d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3688
diff changeset
   365
    "Modified (comment): / 13-02-2017 / 20:35:30 / cg"
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   366
! !
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   367
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   368
!XPMReader methodsFor:'reading'!
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   369
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   370
readImage
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   371
    "read an XPM-image from my inStream. Return the receiver
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   372
     (with all relevant instance variables set for the image)"
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   373
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   374
    |line
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   375
     srcIndex "{ Class: SmallInteger }"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   376
     dstIndex "{ Class: SmallInteger }"
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   377
     colorMapSize
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   378
     s bitsPerPixel bytesPerPixel
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   379
     key lastKey lastChar1 lastChar2
3091
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   380
     c1 c2 lastXLation clr|
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   381
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   382
    line := inStream nextLine.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   383
    (line notNil and:[line startsWith:'/* XPM']) ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   384
        ^ self fileFormatError:'format error (expected XPM)'.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   385
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   386
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   387
    line := inStream nextLine.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   388
    [line notNil and:[(line startsWith:'/*') or:[line isBlank or:[(line startsWith:' *')]]]] whileTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   389
        line := inStream nextLine.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   390
    ].
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   391
    line isNil ifTrue:[
1882
34b809b880a9 read new xpm files (with 'static const char' - line)
Claus Gittinger <cg@exept.de>
parents: 1858
diff changeset
   392
        ^ self fileFormatError:'format error (unexpected end of file)'.
34b809b880a9 read new xpm files (with 'static const char' - line)
Claus Gittinger <cg@exept.de>
parents: 1858
diff changeset
   393
    ].
34b809b880a9 read new xpm files (with 'static const char' - line)
Claus Gittinger <cg@exept.de>
parents: 1858
diff changeset
   394
    ((line startsWith:'static char') or:[(line startsWith:'static const char')]) ifFalse:[
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   395
        ^ self fileFormatError:'format error (expected static char)'.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   396
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   397
    line := inStream nextLine.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   398
    (line notNil and:[line startsWith:'/*']) ifTrue:[
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   399
        [line notNil
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   400
         and:[(line startsWith:'/*') or:[line startsWith:' *']]] whileTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   401
            line := inStream nextLine.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   402
        ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   403
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   404
    line notNil ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   405
        line := line withoutSeparators
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   406
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   407
    (line notNil and:[line startsWith:'"']) ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   408
        ^ self fileFormatError:'format error (expected "ww hh nn mm)'.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   409
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   410
    s := ReadStream on:line.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   411
    s next.  "skip quote"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   412
    width := Integer readFrom:s.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   413
    height := Integer readFrom:s.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   414
    colorMapSize := Integer readFrom:s.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   415
    charsPerPixel := Integer readFrom:s.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   416
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   417
    self reportDimension.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   418
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   419
    charsPerPixel ~~ 1 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   420
        characterTranslation := Dictionary new:colorMapSize.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   421
    ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   422
        characterTranslation := Array new:256.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   423
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   424
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   425
    self readColorMap:colorMapSize.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   426
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   427
    "actually, could make it an image with less depth most of the time ..."
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   428
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   429
"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   430
    bitsPerPixel := ((colorMapSize - 1) log:2) truncated + 1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   431
"
3091
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   432
    colorMapSize > 16r100 ifTrue:[
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   433
        colorMapSize > 16r10000 ifTrue:[
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   434
            bitsPerPixel := 24.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   435
            bytesPerPixel := 3.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   436
        ] ifFalse:[
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   437
            bitsPerPixel := 16.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   438
            bytesPerPixel := 2.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   439
        ].
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   440
    ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   441
        bitsPerPixel := 8.
3091
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   442
        bytesPerPixel := 1.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   443
    ].
3091
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   444
    data := ByteArray new:(width * bytesPerPixel * height).
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   445
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   446
    dstIndex := 1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   447
    1 to:height do:[:row |
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   448
        line := inStream nextLine withoutSpaces.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   449
        [line notNil and:[line startsWith:'/*']] whileTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   450
            line := inStream nextLine withoutSpaces.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   451
        ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   452
        line notNil ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   453
            line := line withoutSeparators
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   454
        ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   455
        (line notNil and:[line startsWith:'"']) ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   456
            ^ self fileFormatError:'format error (expected pixels)'.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   457
        ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   458
        charsPerPixel == 1 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   459
            srcIndex := 2. "skip dquote"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   460
            1 to:width do:[:col |
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   461
                key := line at:srcIndex.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   462
                key ~~ lastKey ifTrue:[
1952
5009754ae556 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 1907
diff changeset
   463
                    lastXLation := characterTranslation at:key codePoint.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   464
                    lastKey := key
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   465
                ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   466
                data at:dstIndex put:lastXLation.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   467
                srcIndex := srcIndex + 1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   468
                dstIndex := dstIndex + 1
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   469
            ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   470
        ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   471
            charsPerPixel == 2 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   472
                "/ sorry, but this ugly code does a lot for speed,
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   473
                "/ when reading big Xpm files (factor=5 for banner8.xpm)  ...
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   474
                srcIndex := 2."skip dquote"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   475
                lastChar1 := lastChar2 := nil.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   476
                key := String new:2.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   477
                1 to:width do:[:col |
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   478
                    c1 := line at:srcIndex.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   479
                    c2 := line at:srcIndex+1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   480
                    (c1 ~~ lastChar1 or:[c2 ~~ lastChar2]) ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   481
                        key at:1 put:c1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   482
                        key at:2 put:c2.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   483
                        lastXLation := characterTranslation at:key.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   484
                        lastChar1 := c1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   485
                        lastChar2 := c2.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   486
                    ].
3091
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   487
                    bitsPerPixel == 8 ifTrue:[
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   488
                        data at:dstIndex put:lastXLation.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   489
                        dstIndex := dstIndex + 1.
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   490
                    ] ifFalse:[
3091
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   491
                        bitsPerPixel == 16 ifTrue:[
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   492
                            data at:dstIndex   put:(lastXLation bitAnd:16rFF).
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   493
                            data at:dstIndex+1 put:((lastXLation bitShift:-8) bitAnd:16rFF).
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   494
                            dstIndex := dstIndex + 2.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   495
                        ] ifFalse:[
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   496
                            clr := colorMap at:lastXLation+1.
3091
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   497
                            data at:dstIndex   put:clr redByte.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   498
                            data at:dstIndex+1 put:clr greenByte.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   499
                            data at:dstIndex+2 put:clr blueByte.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   500
                            dstIndex := dstIndex + 3.
5f05dc4d3a10 class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 2803
diff changeset
   501
                        ]
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   502
                    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   503
                    srcIndex := srcIndex + 2.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   504
                ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   505
            ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   506
                s := line readStream.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   507
                s next. "/ skip dquote
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   508
                1 to:width do:[:col |
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   509
                    key := s next:charsPerPixel.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   510
"/                data at:dstIndex put:(characterTranslation at:key).
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   511
                    key ~= lastKey ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   512
                        lastXLation := characterTranslation at:key.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   513
                        lastKey := key
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   514
                    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   515
                    data at:dstIndex put:lastXLation.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   516
                    dstIndex := dstIndex + 1
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   517
                ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   518
            ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   519
        ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   520
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   521
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   522
    bitsPerPixel == 24 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   523
        photometric := #rgb.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   524
        samplesPerPixel := 3.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   525
        bitsPerSample := #(8 8 8).
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   526
    ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   527
        photometric := #palette.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   528
        samplesPerPixel := 1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   529
        bitsPerSample := Array with:bitsPerPixel.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   530
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   531
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   532
    maskPixelValue notNil ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   533
        self buildMaskFromColor:maskPixelValue
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   534
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   535
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   536
    "
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   537
     XPMReader fromStream:('../../goodies/bitmaps/xpmBitmaps/FATAL.xpm' asFilename readStream)
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   538
    "
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   539
3894
6eef17e67485 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
   540
    "Created: / 24-09-1995 / 06:20:06 / claus"
6eef17e67485 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
   541
    "Modified: / 05-07-1996 / 17:27:59 / stefan"
6eef17e67485 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
   542
    "Modified: / 27-07-1998 / 20:01:56 / cg"
6eef17e67485 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
   543
    "Modified (comment): / 17-02-2017 / 08:54:06 / cg"
3960
13e476fba3bb #REFACTORING by mawalch
mawalch
parents: 3894
diff changeset
   544
    "Modified (comment): / 19-06-2017 / 19:36:39 / mawalch"
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   545
! !
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   546
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   547
!XPMReader methodsFor:'writing'!
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   548
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   549
save:image onFile:aFileName
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   550
    "save image as XPM file on aFileName.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   551
     Caveat: currently, only a maximum of roughly 50 colors is handled
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   552
             (i.e. very simple images)"
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   553
1812
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   554
    imageName := aFileName asFilename baseName asFilename withoutSuffix asString.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   555
    imageName replaceAll:$. with:$_.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   556
1814
2f204c2a957d image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   557
    super save:image onFile:aFileName.
1812
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   558
!
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   559
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   560
save:image onStream:aStream
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   561
    "save image as XPM file on aStream.
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   562
     Caveat: currently, only a maximum of 256 colors is handled
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   563
            (i.e. very simple images)"
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   564
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   565
    |usedColors nColorsUsed nColors nChars map maskColorIndex
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   566
     isMasked imageMask|
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   567
1858
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   568
    usedColors := image usedColorsMax:4096.
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   569
    usedColors isNil ifTrue:[
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   570
        ^ Image cannotRepresentImageSignal 
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   571
            raiseWith:image
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   572
            errorString:('XPMReader cannot represent this image (too many colors)').
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   573
    ].
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   574
3770543620e2 better error report for too many colors
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   575
    usedColors := usedColors asArray.
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   576
    nColors := nColorsUsed := usedColors size.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   577
    (imageMask := image mask) notNil ifTrue:[
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   578
        nColors := nColors + 1.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   579
        maskColorIndex := nColors.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   580
    ].
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   581
    nColors > 256 ifTrue:[
461
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   582
        ^ Image cannotRepresentImageSignal 
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   583
            raiseWith:image
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   584
            errorString:('XPMReader cannot represent this image (too many colors)').
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   585
    ].
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   586
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   587
    map := ($a to: $z) asOrderedCollection.
3688
10011de73077 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   588
    map addAll:($A to: $Z) "asOrderedCollection".
10011de73077 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   589
    map addAll:($0 to: $9) "asOrderedCollection".
10011de73077 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   590
    map addAll:#($. $, $` $^ $* $: $; $< $> $? $% $# $& $( $) $- $+ $=) "asOrderedCollection".
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   591
    nChars := 1.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   592
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   593
    nColors > map size ifTrue:[
668
2c741725cc08 allow save of images with up-to 256 colors
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   594
        map := OrderedCollection new.
693
e228da8c7ddf Fix compiler warning.
Stefan Vogel <sv@exept.de>
parents: 668
diff changeset
   595
        $a to: $j do:[:c1 |
668
2c741725cc08 allow save of images with up-to 256 colors
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   596
            map addAll:(($a to: $z) collect:[:c2 | c1 asString , c2 asString]).
2c741725cc08 allow save of images with up-to 256 colors
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   597
        ].
2c741725cc08 allow save of images with up-to 256 colors
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   598
        nChars := 2.
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   599
    ].
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   600
1812
5c902c4135f1 writing onto a stream
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   601
    outStream := aStream.
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   602
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   603
    outStream nextPutLine:'/* XPM */'.
1814
2f204c2a957d image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   604
    outStream nextPutLine:'static char *' , (imageName ? 'unnamed') , '_xpm[] = {'.
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   605
    outStream nextPutLine:'/* width height ncolors chars_per_pixel */'.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   606
    outStream nextPutLine:'"' , image width printString , ' '
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   607
                              , image height printString , ' '
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   608
                              , nColors printString , ' '
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   609
                              , nChars printString , '",'.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   610
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   611
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   612
    outStream nextPutLine:'/* colors */'.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   613
    1 to:nColorsUsed do:[:idx |
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   614
        |clr|
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   615
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   616
        clr := usedColors at:idx.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   617
        outStream nextPutLine:'"' , (map at:idx) asString ,
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   618
                              ' ' , 'c ' , (self colorNameOf:clr) ,
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   619
                              '",'.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   620
    ].
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   621
    maskColorIndex notNil ifTrue:[
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   622
        outStream nextPutLine:'"' , (map at:maskColorIndex) asString ,
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   623
                              ' c none",'.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   624
    ].
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   625
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   626
    outStream nextPutLine:'/* pixels */'.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   627
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   628
    maskColorIndex isNil ifTrue:[
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   629
        isMasked := false
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   630
    ].
560
4cce4f58bbbf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 550
diff changeset
   631
1743
2f206c9f1319 replace $. in c-variables name
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
   632
    0 to:image height - 1 do:[:y |
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   633
        outStream nextPutAll:'"'.
1743
2f206c9f1319 replace $. in c-variables name
Claus Gittinger <cg@exept.de>
parents: 1737
diff changeset
   634
        0 to:image width - 1 do:[:x |
461
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
   635
            |clr idx|
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   636
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   637
            maskColorIndex notNil ifTrue:[
560
4cce4f58bbbf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 550
diff changeset
   638
                isMasked := (imageMask pixelAtX:x y:y) == 0
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   639
            ].
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   640
            isMasked ifTrue:[
668
2c741725cc08 allow save of images with up-to 256 colors
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   641
                outStream nextPutAll:(map at:maskColorIndex) asString
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   642
            ] ifFalse:[
564
8a31b6fbe9a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 562
diff changeset
   643
                clr := image colorAtX:x y:y.
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   644
                idx := usedColors indexOf:clr.
668
2c741725cc08 allow save of images with up-to 256 colors
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   645
                outStream nextPutAll:(map at:idx) asString
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   646
            ]
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   647
        ].
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   648
        outStream nextPutLine:'",'.
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   649
    ].
469
7b58a1bf581c dont forget to close the stream at the end
Claus Gittinger <cg@exept.de>
parents: 461
diff changeset
   650
    outStream nextPutLine:'};'.
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   651
1012
8dd3d70caedb oops - usedColors returns a set.
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   652
    "Modified: / 28.7.1998 / 21:52:13 / cg"
459
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   653
! !
9cdd02f994a4 added image writing support
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   654
384
f139a7fc423b fixed color reading - color names may consist of multiple
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   655
!XPMReader class methodsFor:'documentation'!
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   656
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   657
version
3688
10011de73077 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   658
    ^ '$Header$'
2803
b1f0edb9c078 changed: #isValidImageFile:
Claus Gittinger <cg@exept.de>
parents: 2030
diff changeset
   659
!
b1f0edb9c078 changed: #isValidImageFile:
Claus Gittinger <cg@exept.de>
parents: 2030
diff changeset
   660
b1f0edb9c078 changed: #isValidImageFile:
Claus Gittinger <cg@exept.de>
parents: 2030
diff changeset
   661
version_CVS
3688
10011de73077 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 3419
diff changeset
   662
    ^ '$Header$'
203
a38debd57097 commentary
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
   663
! !
1650
916067641a59 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   664
3419
2e30918fce3a class: XPMReader
Claus Gittinger <cg@exept.de>
parents: 3091
diff changeset
   665
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   666
XPMReader initialize!