Colormap.st
author Claus Gittinger <cg@exept.de>
Thu, 02 May 1996 17:31:02 +0200
changeset 637 08e099c202db
parent 636 cb58286c27ad
child 665 843bf13683f5
permissions -rw-r--r--
oops - had to undo 0-based indexing (some images use arrays as colormap)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     1
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     3
	      All Rights Reserved
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     4
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    11
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    12
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
    13
SequenceableCollection subclass:#Colormap
572
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    14
	instanceVariableNames:'redVector greenVector blueVector'
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    15
	classVariableNames:''
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    16
	poolDictionaries:''
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    17
	category:'Graphics-Images support'
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    18
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    19
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    20
!Colormap class methodsFor:'documentation'!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    21
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    22
copyright
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    23
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    25
	      All Rights Reserved
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    26
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    27
 This software is furnished under a license and may be used
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    32
 hereby transferred.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    33
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    34
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    35
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    36
documentation
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    37
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    38
    Colormaps are used with images (and Forms) to keep the byte-to-color
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    39
    mapping.
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    40
    Externally, either colors or pixel values can be accessed.
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    41
    Internally, the values are stored as 3 separate byte-arrays
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    42
    (i.e. individual components can be 0..255).
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    43
    This was done to avoid overhead due to allocation of many color
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    44
    instances.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    45
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
    46
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
    47
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
    48
        Claus Gittinger
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
    49
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    50
    [see also:]
603
7e2b1e471427 commentary
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
    51
        Color Image Form
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    52
"
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    53
! !
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    54
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    55
!Colormap class methodsFor:'instance creation'!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    56
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    57
fromColors:aColorArray
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    58
    "given a collection of real colors, return a new instance
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    59
     of myself"
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    60
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    61
    |n rV gV bV|
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    62
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    63
    n := aColorArray size.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    64
    rV := ByteArray new:n.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    65
    gV := ByteArray new:n.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    66
    bV := ByteArray new:n.
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    67
    1 to:n do:[:i |
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    68
        |clr|
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    69
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    70
        clr := aColorArray at:i.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    71
        rV at:i put:(clr red * 255 / 100) rounded.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    72
        bV at:i put:(clr green * 255 / 100) rounded.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    73
        gV at:i put:(clr blue * 255 / 100) rounded.
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    74
    ].
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    75
    ^ self new redVector:rV greenVector:gV blueVector:bV
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    76
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    77
    "
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    78
     Colormap 
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    79
        fromColors:(Array with:Color black
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    80
                          with:Color red
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    81
                          with:Color white)
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
    82
    "
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    83
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    84
    "Modified: 23.4.1996 / 22:15:22 / cg"
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    85
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    86
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    87
redVector:r greenVector:g blueVector:b
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    88
    "given vectors of red/green/and blue pixelValues,
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    89
     return a new instance of myself.
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    90
     The values must be in the range 0..255."
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    91
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    92
    ^ self new redVector:r greenVector:g blueVector:b
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
    93
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    94
    "
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    95
     Colormap 
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    96
        redVector:#[0 127 255]
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    97
        greenVector:#[0 127 255]
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
    98
        blueVector:#[0 127 255]
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    99
    "
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   100
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   101
    "Modified: 23.4.1996 / 22:16:00 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   102
! !
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   103
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   104
!Colormap methodsFor:'accessing'!
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   105
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   106
at:index 
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   107
    "return the color for a index. 
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   108
     Notice that index range is 1..."
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   109
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   110
    |r g b idx "{ Class: SmallInteger }" |
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   111
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   112
    idx := index.
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   113
    r := redVector at:idx.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   114
    g := greenVector at:idx.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   115
    b := blueVector at:idx.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   116
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   117
    ^ Color
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   118
        red:(r * 100 / 255)
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   119
        green:(g * 100 / 255)
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   120
        blue:(b * 100 / 255)
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   121
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   122
    "Created: 2.5.1996 / 12:21:40 / cg"
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   123
    "Modified: 2.5.1996 / 17:29:24 / cg"
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   124
!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   125
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   126
at:index put:aColor
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   127
    "set the color for a index. Return aColor (sigh).
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   128
     Notice that index range is 1..."
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   129
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   130
    |r g b idx "{ Class: SmallInteger }" |
572
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   131
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   132
    r := (aColor red * 255 / 100) rounded.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   133
    g := (aColor green * 255 / 100) rounded.
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   134
    b := (aColor blue * 255 / 100) rounded.
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   135
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   136
    idx := index.
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   137
    redVector at:idx put:r.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   138
    greenVector at:idx put:g.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   139
    blueVector at:idx put:b.
572
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   140
    ^ aColor
b164eb8a3e6e commentary
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   141
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   142
    "Modified: 2.5.1996 / 17:29:29 / cg"
118
25e775072a89 *** empty log message ***
claus
parents: 91
diff changeset
   143
!
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   144
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   145
blueAt:index
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   146
    "return the blue component for some index.
153
claus
parents: 118
diff changeset
   147
     The returned value is scaled from the internal 0.. 255 to
claus
parents: 118
diff changeset
   148
     a percentage value 0..100"
claus
parents: 118
diff changeset
   149
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   150
    ^ (blueVector at:index) * 100 / 255
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   151
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   152
    "Modified: 2.5.1996 / 17:29:17 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   153
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   154
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   155
colors
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   156
    "ST-80 compatibility: return a collection containing the colors I hold"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   157
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   158
    ^ self asArray
153
claus
parents: 118
diff changeset
   159
!
claus
parents: 118
diff changeset
   160
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   161
greenAt:index
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   162
    "return the green component for some index.
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   163
     The returned value is scaled from the internal 0.. 255 to
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   164
     a percentage value 0..100"
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   165
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   166
    ^ (greenVector at:index) * 100 / 255
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   167
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   168
    "Modified: 2.5.1996 / 17:29:36 / cg"
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   169
!
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   170
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   171
redAt:index
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   172
    "return the red component for some index.
153
claus
parents: 118
diff changeset
   173
     The returned value is scaled from the internal 0.. 255 to
claus
parents: 118
diff changeset
   174
     a percentage value 0..100"
claus
parents: 118
diff changeset
   175
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   176
    ^ (redVector at:index) * 100 / 255
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   177
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   178
    "Modified: 2.5.1996 / 17:29:44 / cg"
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   179
!
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   180
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   181
size
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   182
    "return the number of colors in the receiver"
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   183
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   184
    ^ redVector size
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   185
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   186
    "Modified: 23.4.1996 / 22:13:43 / cg"
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   187
! !
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   188
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   189
!Colormap methodsFor:'accessing - internals'!
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   190
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   191
blueVector
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   192
    "return the blueVector"
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   193
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   194
    ^ blueVector
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   195
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   196
    "Modified: 2.5.1996 / 12:44:17 / cg"
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   197
!
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   198
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   199
blueVector:something
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   200
    "set blueVector"
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   201
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   202
    blueVector := something.
153
claus
parents: 118
diff changeset
   203
!
claus
parents: 118
diff changeset
   204
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   205
greenVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   206
    "return greenVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   207
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   208
    ^ greenVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   209
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   210
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   211
greenVector:something
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   212
    "set greenVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   213
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   214
    greenVector := something.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   215
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   216
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   217
redVector
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   218
    "return redVector"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   219
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   220
    ^ redVector
153
claus
parents: 118
diff changeset
   221
!
claus
parents: 118
diff changeset
   222
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   223
redVector:something
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   224
    "set redVector"
153
claus
parents: 118
diff changeset
   225
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   226
    redVector := something.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   227
!
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   228
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   229
redVector:r greenVector:g blueVector:b
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   230
    "set the red, green and blueVectors"
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   231
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   232
    redVector := r.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   233
    greenVector := g.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   234
    blueVector := b.
602
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   235
f4827cf7d3f9 commentary
Claus Gittinger <cg@exept.de>
parents: 572
diff changeset
   236
    "Modified: 23.4.1996 / 22:13:31 / cg"
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   237
! !
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   238
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   239
!Colormap methodsFor:'misc'!
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   240
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   241
scaleValuesBy:scaleFactor
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   242
    "multiply all values by scaleFactor; finally round to integer.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   243
     This can be used to brighten/darken an images colormap"
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   244
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   245
    |sz "{ Class: SmallInteger }" |
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   246
635
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   247
    sz := redVector size.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   248
    1 to:sz do:[:index |
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   249
        redVector at:index put:((redVector at:index) * scaleFactor) rounded.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   250
        greenVector at:index put:((greenVector at:index) * scaleFactor) rounded.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   251
        blueVector at:index put:((blueVector at:index) * scaleFactor) rounded.
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   252
    ]
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   253
1e1c3f870ba8 colorMap is now 0-index based (more compatibility with ST-80's Palette)
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   254
    "Modified: 2.5.1996 / 12:46:07 / cg"
91
03c73c3b1d57 Initial revision
claus
parents:
diff changeset
   255
! !
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   256
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   257
!Colormap class methodsFor:'documentation'!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   258
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   259
version
637
08e099c202db oops - had to undo 0-based indexing (some images use arrays as colormap)
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   260
    ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.12 1996-05-02 15:31:02 cg Exp $'
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   261
! !