#REFACTORING by cg
class: Image
added: #bytesPerRowForWidth:bitsPerPixel:
changed: #bytesPerRow
common code eliminated
--- a/Image.st Thu Feb 16 17:29:05 2017 +0100
+++ b/Image.st Thu Feb 16 17:29:30 2017 +0100
@@ -2001,6 +2001,21 @@
!Image class methodsFor:'misc'!
+bytesPerRowForWidth:width bitsPerPixel:bitsPerPixel
+ "return the number of bytes in one scanline of an image."
+
+ |bitsPerRow bytesPerRow|
+
+ bitsPerRow := width * bitsPerPixel.
+ bytesPerRow := bitsPerRow // 8.
+ ((bitsPerRow \\ 8) ~~ 0) ifTrue:[
+ bytesPerRow := bytesPerRow + 1
+ ].
+ ^ bytesPerRow
+
+ "Created: / 16-02-2017 / 16:17:42 / cg"
+!
+
ditherAlgorithm
"return the way we dither -
#threshold, or nil -> no dither
@@ -13519,14 +13534,9 @@
bytesPerRow
"return the number of bytes in one scanline of the image"
- |bitsPerRow bytesPerRow|
-
- bitsPerRow := width * (self bitsPerPixel).
- bytesPerRow := bitsPerRow // 8.
- ((bitsPerRow \\ 8) ~~ 0) ifTrue:[
- bytesPerRow := bytesPerRow + 1
- ].
- ^ bytesPerRow
+ ^ self class bytesPerRowForWidth:width bitsPerPixel:(self bitsPerPixel)
+
+ "Modified: / 16-02-2017 / 16:17:59 / cg"
!
bytesPerRowPaddedTo:padding