--- a/WindowsIconReader.st Sat Mar 05 15:16:12 2016 +0100
+++ b/WindowsIconReader.st Sat Mar 05 15:34:48 2016 +0100
@@ -38,7 +38,8 @@
documentation
"
- this class provides methods for loading Windows and OS2 icon files.
+ this class provides methods for loading Windows and OS2 icon and bmp files.
+ The name is misleading, but due to historic reasons.
Image writing is only supported for BMP format with depth 1,4,8 and 24 bit images.
The reader tries to figure out which version of BMP/ICO is used.
@@ -302,6 +303,18 @@
!WindowsIconReader methodsFor:'private'!
+swapBytesFromRGBA_to_BGRA
+ |idx bytesPerRow|
+
+ "/ Depth32Image keeps its data r/g/b/a; BMP has it b/g/r/a (sigh)
+ idx := 1.
+ bytesPerRow := self bytesPerRow.
+ 1 to:height do:[:y |
+ self class swap:width pixelsFromRGB_to_BGR_in:data startingAt:idx bytesPerPixel:4.
+ idx := idx + bytesPerRow.
+ ].
+!
+
swapBytesFromRGB_to_BGR
|idx bytesPerRow|
@@ -309,8 +322,8 @@
idx := 1.
bytesPerRow := self bytesPerRow.
1 to:height do:[:y |
- self class swap:bytesPerRow bytesFromRGB_to_BGR_in:data startingAt:idx.
- idx := idx + bytesPerRow.
+ self class swap:width pixelsFromRGB_to_BGR_in:data startingAt:idx bytesPerPixel:3.
+ idx := idx + bytesPerRow.
].
! !
@@ -426,6 +439,10 @@
"/ Depth24Image keeps its data r/g/b; BMP has it b/g/r (sigh)
self swapBytesFromRGB_to_BGR.
].
+ inDepth == 32 ifTrue:[
+ "/ Depth32Image keeps its data r/g/b/a; BMP has it b/g/r/a (sigh)
+ self swapBytesFromRGBA_to_BGRA.
+ ].
^ true
].