fixed bmp saving 24bit image (red & blue channels exchanged)
authorClaus Gittinger <cg@exept.de>
Thu, 13 Sep 2001 15:00:36 +0200
changeset 1507 9bae072abf64
parent 1506 60e56746dce6
child 1508 7e77864d74d2
fixed bmp saving 24bit image (red & blue channels exchanged)
WindowsIconReader.st
--- a/WindowsIconReader.st	Thu Sep 13 11:01:37 2001 +0200
+++ b/WindowsIconReader.st	Thu Sep 13 15:00:36 2001 +0200
@@ -897,7 +897,7 @@
     "save image as BMP file on aFileName.
      Only depth 1,4,8 and 24 images can be represented in this format."
 
-    |depth bhSize biSize biClrUsed biSizeImage bfOffBits rowBytes imgBytesPerRow data srcIndex row|
+    |depth bhSize biSize biClrUsed biSizeImage bfOffBits rowBytes imgBytesPerRow data srcIndex row t|
 
     depth := image depth.
     width := image width.
@@ -978,6 +978,15 @@
     1 to:height do:[:i |
         srcIndex := srcIndex - imgBytesPerRow.
         row replaceFrom:1 to:imgBytesPerRow with:data startingAt:srcIndex.
+        depth >= 24 ifTrue:[
+            "/ stupid must swap red & blue bytes
+
+            1 to:row size by:3 do:[:i |
+                t := row at:i.
+                row at:i put:(row at:i+2).
+                row at:i+2 put:t
+            ].
+        ].
         outStream nextPutAll:row.
     ].
 
@@ -1112,6 +1121,6 @@
 !WindowsIconReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.48 2000-08-02 10:15:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.49 2001-09-13 13:00:36 cg Exp $'
 ! !
 WindowsIconReader initialize!