equal
deleted
inserted
replaced
1213 #translateLabel: true |
1213 #translateLabel: true |
1214 #value: #sortColorMap |
1214 #value: #sortColorMap |
1215 #enabled: #hasColormap |
1215 #enabled: #hasColormap |
1216 ) |
1216 ) |
1217 #(#MenuItem |
1217 #(#MenuItem |
|
1218 #label: 'Clear masked pixels' |
|
1219 #translateLabel: true |
|
1220 #value: #clearMaskedPixels |
|
1221 ) |
|
1222 #(#MenuItem |
1218 #label: '-' |
1223 #label: '-' |
1219 ) |
1224 ) |
1220 #(#MenuItem |
1225 #(#MenuItem |
1221 #label: 'Reduce number of colors...' |
1226 #label: 'Reduce number of colors...' |
1222 #translateLabel: true |
1227 #translateLabel: true |
2121 |
2126 |
2122 "Created: / 12.3.1999 / 00:20:28 / cg" |
2127 "Created: / 12.3.1999 / 00:20:28 / cg" |
2123 "Modified: / 16.3.1999 / 21:57:26 / cg" |
2128 "Modified: / 16.3.1999 / 21:57:26 / cg" |
2124 ! |
2129 ! |
2125 |
2130 |
|
2131 clearMaskedPixels |
|
2132 "clear all masked pixels (to pixelValue 0)" |
|
2133 |
|
2134 |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
|
2135 |
|
2136 oldImage := self image. |
|
2137 |
|
2138 imageEditView makeUndo. |
|
2139 |
|
2140 self withExecuteCursorDo:[ |
|
2141 newImage := oldImage clearMaskedPixels. |
|
2142 (imageEditView image:newImage) notNil ifTrue:[ |
|
2143 self listOfColors contents: newImage colorMap. |
|
2144 self findColorMapMode. |
|
2145 self updateLabelsAndHistory. |
|
2146 self halt. |
|
2147 ] |
|
2148 ] |
|
2149 ! |
|
2150 |
2126 colorMapChanged |
2151 colorMapChanged |
2127 |img| |
2152 |img| |
2128 |
2153 |
2129 img := self image. |
2154 img := self image. |
2130 img release. |
2155 img release. |
2183 newColorMap at:(pixel+1) put:(oldImage colorFromValue:pixel) |
2208 newColorMap at:(pixel+1) put:(oldImage colorFromValue:pixel) |
2184 ]. |
2209 ]. |
2185 ] ifFalse:[ |
2210 ] ifFalse:[ |
2186 "/ see if all used color fit the new colormap |
2211 "/ see if all used color fit the new colormap |
2187 usedColors := oldImage usedColorsMax:(1 bitShift:depth). |
2212 usedColors := oldImage usedColorsMax:(1 bitShift:depth). |
|
2213 (usedColors notNil and:[usedColors size > (1 bitShift:depth)]) ifTrue:[ |
|
2214 usedColors := oldImage realUsedColors |
|
2215 ]. |
2188 (usedColors notNil and:[usedColors size <= (1 bitShift:depth)]) ifTrue:[ |
2216 (usedColors notNil and:[usedColors size <= (1 bitShift:depth)]) ifTrue:[ |
2189 "/ yea - just install them |
2217 "/ yea - just install them |
2190 usedColors asArray keysAndValuesDo:[:idx :clr | |
2218 usedColors asArray keysAndValuesDo:[:idx :clr | |
2191 newColorMap at:idx put:clr |
2219 newColorMap at:idx put:clr |
2192 ]. |
2220 ]. |
2337 oldImage photometric ~~ #palette ifTrue:[ |
2365 oldImage photometric ~~ #palette ifTrue:[ |
2338 self information:'Compress colorMap: Only palette images have colormaps.'. |
2366 self information:'Compress colorMap: Only palette images have colormaps.'. |
2339 ^ self |
2367 ^ self |
2340 ]. |
2368 ]. |
2341 |
2369 |
2342 usedColors := oldImage usedColors. |
2370 usedColors := oldImage realUsedColors. |
2343 usedColors size == (1 bitShift:depth) ifTrue:[ |
2371 usedColors size == (1 bitShift:depth) ifTrue:[ |
2344 self information:'Compress colorMap: All colors are used - no compression.'. |
2372 self information:'Compress colorMap: All colors are used - no compression.'. |
2345 ^ self |
2373 ^ self |
2346 ]. |
2374 ]. |
2347 usedColors size == oldImage colorMap size ifTrue:[ |
2375 usedColors size == oldImage colorMap size ifTrue:[ |