ImageReader.st
changeset 7501 ddcd558eda4b
parent 7375 9675ac6ee423
child 7539 cf0fed88ba16
--- a/ImageReader.st	Mon Aug 08 17:13:09 2016 +0200
+++ b/ImageReader.st	Tue Aug 09 04:37:45 2016 +0200
@@ -1231,6 +1231,31 @@
     "Modified: 23.4.1997 / 18:54:05 / cg"
 !
 
+swap:nBytes bytesFromRGBA_to_BGRA_in:data startingAt:startIndex
+    "swap bytes from RGBA into BGRA order.
+     The argument is a pixel data buffer (byteArray)"
+
+    self swap:(nBytes//4) pixelsFromRGB_to_BGR_in:data startingAt:startIndex bytesPerPixel:4
+
+    "
+     |bytes|
+
+     bytes := #[ 0 1 2 3 4 5 6 7 8 9 ].
+     self swap:6 bytesFromRGB_to_BGR_in:bytes startingAt:1.
+     bytes.
+    "
+    "
+     |bytes|
+
+     bytes := ByteArray new:1000000.
+     bytes replaceFrom:1 with:#[ 0 1 2 3 4 5 6 7 8 9 10 11 12].
+     Time millisecondsToRun:[
+        self swap:1000000 bytesFromRGB_to_BGR_in:bytes.
+     ].
+     bytes copyTo:10.
+    "
+!
+
 swap:nBytes bytesFromRGB_to_BGR_in:data
     "swap bytes from RGB into BGR order.
      The argument is a pixel data buffer (byteArray)"