#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Thu, 16 Feb 2017 17:29:30 +0100
changeset 7898 05e286976596
parent 7897 de53f0853c91
child 7899 c32cbefff86a
#REFACTORING by cg class: Image added: #bytesPerRowForWidth:bitsPerPixel: changed: #bytesPerRow common code eliminated
Image.st
--- 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