--- a/ImageReader.st Wed Apr 02 19:45:31 2003 +0200
+++ b/ImageReader.st Thu Apr 03 12:32:14 2003 +0200
@@ -1540,6 +1540,51 @@
%}
"Modified: 22.4.1996 / 19:14:54 / cg"
+!
+
+swap:nBytes bytesFromRGB_to_BGR_in:data
+ "swap bytes from RGB into BGR order.
+ The argument is a pixel data buffer (byteArray)"
+
+%{ /* OPTIONAL */
+ if (__isByteArray(data) && __isSmallInteger(nBytes)) {
+ int __nBytes = __intVal(nBytes);
+ int __dataSize = __byteArraySize(data);
+
+ if (__nBytes <= __dataSize) {
+ int __lastIndex = __nBytes - 2;
+ unsigned char *__cp = __ByteArrayInstPtr(data)->ba_element;
+ int __i;
+ unsigned char __t;
+
+ for (__i=0; __i<__lastIndex; __i+=3, __cp+=3) {
+ __t = __cp[0];
+ __cp[0] = __cp[2];
+ __cp[2] = __t;
+ }
+ RETURN (true);
+ }
+ }
+%}.
+ self primitiveFailed.
+
+ "
+ |bytes|
+
+ bytes := #[ 0 1 2 3 4 5 6 7 8 9 ].
+ self swap:6 bytesFromRGB_to_BGR_in:bytes.
+ 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.
+ "
! !
!ImageReader class methodsFor:'i/o support'!
@@ -2150,5 +2195,5 @@
!ImageReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.76 2002-02-26 13:03:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.77 2003-04-03 10:32:14 cg Exp $'
! !