--- a/Image.st Thu Oct 12 14:17:22 2017 +0200
+++ b/Image.st Thu Oct 12 16:45:16 2017 +0200
@@ -10008,7 +10008,7 @@
"draw a line with some pixel value.
This is in no way tuned, as normally, display-forms are used to draw.
The only use for this is when we have to generate images in a headless webService
- (such as the HumanReadableImageGenerator).
+ (such as the HumanReadableImageGenerator) or in the image editor.
If aPixelValueOrNil is nil, the mask pixel will be set to 0 (transparent),
otherwise to 1. (used by the bitmap editor)"
@@ -10019,6 +10019,19 @@
x1 := endPoint x.
y1 := endPoint y.
+ (x1 - x0) == 0 ifTrue:[
+ y0 to: y1 do:[:y |
+ self atImageAndMask:x0@y putValue:aPixelValueOrNil.
+ ].
+ ^ self.
+ ].
+ (y1 - y0) == 0 ifTrue:[
+ x0 to: x1 do:[:x |
+ self atImageAndMask:x@y0 putValue:aPixelValueOrNil.
+ ].
+ ^ self.
+ ].
+
steep := (y1 - y0) abs > (x1 - x0) abs.
steep ifTrue:[
t := x0. x0 := y0. y0 := t.
@@ -10032,19 +10045,6 @@
deltax := x1 - x0.
deltay := (y1 - y0) abs.
- deltax == 0 ifTrue:[
- y0 to: y1 do:[:y |
- self atImageAndMask:x0@y putValue:aPixelValueOrNil.
- ].
- ^ self.
- ].
- deltay == 0 ifTrue:[
- x0 to: x1 do:[:x |
- self atImageAndMask:x@y0 putValue:aPixelValueOrNil.
- ].
- ^ self.
- ].
-
error := 0.
deltaerr := deltay / deltax.
y := y0.
@@ -10417,11 +10417,20 @@
hI := h.
p := Point new.
- yI to:yI+hI-1 do:[:yRun |
- xI to:xI+wI-1 do:[:xRun |
- p x:xRun y:yRun.
- self atImageAndMask:p putValue:aPixelValueOrNil.
- ]
+ mask isNil ifTrue:[
+ yI to:yI+hI-1 do:[:yRun |
+ xI to:xI+wI-1 do:[:xRun |
+ p x:xRun y:yRun.
+ self pixelAt:p put:(aPixelValueOrNil ? 0).
+ ]
+ ].
+ ] ifFalse:[
+ yI to:yI+hI-1 do:[:yRun |
+ xI to:xI+wI-1 do:[:xRun |
+ p x:xRun y:yRun.
+ self atImageAndMask:p putValue:aPixelValueOrNil.
+ ]
+ ].
].
self release. "/ device-image is no longer valid
@@ -13477,6 +13486,8 @@
!Image methodsFor:'initialization'!
createPixelStore
+ "instantiate the underlying pixel storage (a byteArray)"
+
|bytesPerRow|
bytesPerRow := self bytesPerRow.