#BUGFIX by cg
class: Image
changed:
#asDitheredImageUsing:depth:
#fromImage:photometric:
#realColorMap
--- a/Image.st Thu Aug 24 17:03:37 2017 +0200
+++ b/Image.st Thu Aug 24 17:56:07 2017 +0200
@@ -4703,7 +4703,19 @@
samplesPerPixel := self samplesPerPixel.
photometricOrNil isNil ifTrue:[
- photometric := self class defaultPhotometric
+ (self depth <= 8) ifTrue:[
+ anImage isGrayscaleImage ifTrue:[
+ self photometric:#blackIs0
+ ] ifFalse:[
+ (anImage usedColorsMax:4096) size <= (1 bitShift:self depth) ifTrue:[
+ self photometric:#palette.
+ self colorMap:(anImage usedColors asArray)
+ ]
+ ].
+ ] ifFalse:[
+ photometric := self class defaultPhotometric.
+ ].
+
"/ photometric := anImage photometric
] ifFalse:[
photometricOrNil == #rgba ifTrue:[
@@ -4830,7 +4842,7 @@
"
"Modified (format): / 30-01-2017 / 20:46:22 / stefan"
- "Modified: / 04-08-2017 / 17:09:02 / cg"
+ "Modified: / 24-08-2017 / 17:28:25 / cg"
!
fromSubImage:anImage in:aRectangle
@@ -5081,15 +5093,23 @@
"return a dithered image from the picture,
using colors in colors for dithering."
- |newBits|
+ |newBits img8|
newBits := self floydSteinbergDitheredDepth8BitsColors:colors map:(0 to:colors size - 1).
newBits isNil ifTrue:[
self error:'dithering failed'
].
+ d ~~ 8 ifTrue:[
+ img8 := Depth8Image new extent:(self extent).
+ img8 colorMap:colors.
+ img8 bits:newBits.
+ ^ (self class implementorForDepth:d) fromImage:img8.
+ ].
+
^ (self class newForDepth:d) extent:(self extent); depth:d; palette:colors; bits:newBits; yourself
"Modified: / 30-01-2017 / 19:40:19 / stefan"
+ "Modified: / 24-08-2017 / 17:37:12 / cg"
!
asErrorDitheredMonochromeImage
@@ -14306,6 +14326,10 @@
colorArray|
photometric == #palette ifTrue:[
+ "/ should not happen
+ colorMap isNil ifTrue:[
+ ^ Color vgaColors.
+ ].
^ colorMap asArray
].
@@ -14324,8 +14348,8 @@
^ colorArray
- "Created: 11.7.1996 / 20:20:35 / cg"
- "Modified: 11.7.1996 / 20:49:21 / cg"
+ "Created: / 11-07-1996 / 20:20:35 / cg"
+ "Modified: / 24-08-2017 / 17:27:31 / cg"
!
realUsedColors