[squeak-dev] The Inbox: Graphics-kfr.527.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Jul 1 17:15:07 UTC 2022
A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-kfr.527.mcz
==================== Summary ====================
Name: Graphics-kfr.527
Author: kfr
Time: 1 July 2022, 7:15:00.033758 pm
UUID: 45123247-99ec-da41-b9a2-a3680dfe2f66
Ancestors: Graphics-kfr.526
We can't reduce color of 32 bit depth directly.
Convert to 16 bits first to get around problem.
=============== Diff against Graphics-kfr.526 ===============
Item was changed:
----- Method: Form>>copyWithColorsReducedTo: (in category 'converting') -----
copyWithColorsReducedTo: nColors
"Note: this has not been engineered.
There are better solutions in the literature."
| palette colorMap |
+ self depth > 16 ifTrue:[^(self asFormOfDepth: 16) copyWithColorsReducedTo: nColors]. "First reduce to 16 bit depth"
- self depth > 16 ifTrue:[^self]."bail out. will cause problems on 32 bit depth forms"
palette := self reducedPaletteOfSize: nColors.
colorMap := (1 to: (1 bitShift: depth)) collect:
[:i | | pc closest |
pc := Color colorFromPixelValue: i-1 depth: depth.
closest := palette detectMin: [:c | c diff: pc].
closest pixelValueForDepth: depth].
^ self deepCopy copyBits: self boundingBox from: self at: 0 at 0 colorMap: (colorMap as: Bitmap)
!
More information about the Squeak-dev
mailing list
|