[squeak-dev] The Trunk: Graphics-kfr.529.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Aug 10 08:15:58 UTC 2022
Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-kfr.529.mcz
==================== Summary ====================
Name: Graphics-kfr.529
Author: kfr
Time: 8 July 2022, 9:09:08.988763 am
UUID: c82ec469-0674-f04c-9123-0b36fb8eb7d6
Ancestors: Graphics-kfr.528
Floyd Steinberg dither for forms of 1 to 8 bit depth.
=============== Diff against Graphics-kfr.527 ===============
Item was added:
+ ----- Method: Form>>at:bias: (in category 'processing') -----
+ at: aPoint bias: aQuantError
+ | x y color point oldColor |
+ x := aPoint x.
+ y := aPoint y.
+
+ point := (x + 1 min: self width)@ y.
+ oldColor := self colorAt: point.
+ color := oldColor + (aQuantError * 0.4375). "7/16"
+ self colorAt: point put: color.
+
+ point := (x - 1 max: 0)@ (y + 1 min: self height).
+ oldColor := self colorAt: point.
+ color := oldColor + (aQuantError * 0.1875)."3/16"
+ self colorAt: point put: color.
+
+ point := x @ (y + 1 min: self height).
+ oldColor := self colorAt: point.
+ color := oldColor + (aQuantError * 0.3125 ) ."5/16"
+ self colorAt: point put: color.
+
+ point := (x + 1 min: self width) @ (y + 1 min: self height).
+ oldColor := self colorAt: point.
+ color := oldColor + (aQuantError * 0.0625 ) ."1/16"
+ self colorAt: point put: color.
+ !
Item was added:
+ ----- Method: Form>>dither: (in category 'processing') -----
+ dither: aDepth
+ | newColor oldColor quantError result |
+ "Floyd Steinberg dithering for depth 1 to 8 bits"
+ result := self copy.
+ (0 to: height) do:[:y|
+ (0 to: width) do:[:x|
+ oldColor := (result colorAt: x at y).
+ newColor := Color colorFromPixelValue: (oldColor pixelValueForDepth: aDepth) depth: aDepth.
+ result colorAt: x at y put: newColor.
+ quantError := (oldColor - newColor).
+ result at: x at y bias: quantError]].
+ ^result.!
Item was changed:
----- Method: Form>>processUsingKernel:factor:bias: (in category 'processing') -----
processUsingKernel: filter factor: factor bias: bias
+ | image result color |
- | image result |
image := self.
result := Form extent: image extent depth: image depth.
0 to: image height - 1 do: [:y |
0 to: image width - 1 do: [:x |
| r g b |
r := g := b := 0.0.
0 to: filter rowCount - 1 do: [:filterY |
0 to: filter columnCount - 1 do: [:filterX |
| imageX imageY |
imageX := (x - (filter columnCount // 2) + filterX + image width) \\
image width.
imageY := (y - (filter rowCount // 2) + filterY + image height) \\
image height.
+ color := image colorAt: imageX at imageY.
+ r := r + (color red *
- r := r + ((image colorAt: imageX at imageY) red *
(filter at: filterY + 1 at: filterX + 1)).
+ g := g + (color green *
- g := g + ((image colorAt: imageX at imageY) green *
(filter at: filterY + 1 at: filterX + 1)).
+ b := b + (color blue *
- b := b + ((image colorAt: imageX at imageY) blue *
(filter at: filterY + 1 at: filterX + 1))]].
result colorAt: x at y put: (Color
r: ((factor * r + bias) min: 1.0 max: 0.0)
g: ((factor * g + bias) min: 1.0 max: 0.0)
b: ((factor * b + bias) min: 1.0 max: 0.0))]].
^ result
!
More information about the Squeak-dev
mailing list
|