DeviceGraphicsContext.st
changeset 8010 775d6d381f20
parent 8009 d5e22275f8de
child 8027 6fbc6eee1156
--- a/DeviceGraphicsContext.st	Wed Apr 12 14:40:28 2017 +0200
+++ b/DeviceGraphicsContext.st	Wed Apr 12 15:45:44 2017 +0200
@@ -1933,7 +1933,7 @@
 
     (aFormOrImage isImage and:[aFormOrImage photometric == #rgba]) ifTrue:[
         Error handle:[:ex |
-            Logger error:'error when drawinf alpha: %1' with:ex description.
+            Logger error:'error when drawing alpha: %1' with:ex description.
         ] do:[    
             self displayDeviceFormWithAlpha:aFormOrImage x:x y:y.
             ^ self.
@@ -2305,7 +2305,10 @@
      dstIndex "{Class: SmallInteger}"
      imgIndex "{Class: SmallInteger}"
      dstRowIndex "{Class: SmallInteger}"
-     imgRowIndex "{Class: SmallInteger}"|
+     imgRowIndex "{Class: SmallInteger}"
+     oB "{Class: SmallInteger}"
+     oR "{Class: SmallInteger}"
+     oG "{Class: SmallInteger}"|
 
     device sync.
     
@@ -2337,6 +2340,10 @@
         dstRowIndex := 1.
         imgRowIndex := 1.
         
+        oR := 2.
+        oG := 1.
+        oB := 0.
+
         "/ draw "by hand" here
         0 to:h-1 do:[:y |
             dstIndex := dstRowIndex.
@@ -2354,9 +2361,9 @@
                  nG "{Class: SmallInteger}"
                  nB "{Class: SmallInteger}"|
 
-                rD := dstData at:(dstIndex+2).
-                gD := dstData at:(dstIndex+1).
-                bD := dstData at:(dstIndex+0).
+                rD := dstData at:(dstIndex+oR).
+                gD := dstData at:(dstIndex+oG).
+                bD := dstData at:(dstIndex+oB).
 
                 rI := imgData at:(imgIndex).
                 gI := imgData at:(imgIndex+1).
@@ -2402,6 +2409,16 @@
         dstRowIndex := 1.
         imgRowIndex := 1.
 
+        (info at:#byteOrder) == #lsbFirst ifTrue:[
+            oR := 0.
+            oG := 1.
+            oB := 2.
+        ] ifFalse:[
+            oR := 2.
+            oG := 1.
+            oB := 0.
+        ].
+
         "/ draw "by hand" here
         0 to:h-1 do:[:y |
             dstIndex := dstRowIndex.
@@ -2419,9 +2436,9 @@
                  nG "{Class: SmallInteger}"
                  nB "{Class: SmallInteger}"|
 
-                rD := dstData at:(dstIndex+2).
-                gD := dstData at:(dstIndex+1).
-                bD := dstData at:(dstIndex+0).
+                rD := dstData at:(dstIndex+oR).
+                gD := dstData at:(dstIndex+oG).
+                bD := dstData at:(dstIndex+oB).
 
                 rI := imgData at:(imgIndex).
                 gI := imgData at:(imgIndex+1).
@@ -2445,9 +2462,9 @@
                         nB := (((bI * aI)+(bD * aD)) // 255).
                     ].
                 ].
-                dstData at:(dstIndex+0) put:nR.
+                dstData at:(dstIndex+2) put:nR.
                 dstData at:(dstIndex+1) put:nG.
-                dstData at:(dstIndex+2) put:nB.
+                dstData at:(dstIndex+0) put:nB.
 
                 dstIndex := dstIndex + 3.
                 imgIndex := imgIndex + 4.