--- a/ImageReader.st Fri Jul 05 18:20:01 1996 +0200
+++ b/ImageReader.st Fri Jul 05 23:00:17 1996 +0200
@@ -1474,6 +1474,90 @@
!ImageReader methodsFor:'image reading'!
+buildMaskFromColor:maskPixelValue
+ |maskArray bytesPerMaskRow|
+
+ bytesPerMaskRow := (width+7) // 8.
+
+ maskArray := ByteArray new:bytesPerMaskRow * height.
+
+%{
+ int __w = __intVal(__INST(width));
+ int __h = __intVal(__INST(height));
+ int __x, __y;
+ int __outBits, __nOut;
+ unsigned char *__inP, *__outP, *__nextOutRow;
+ int __bpr = __intVal(bytesPerMaskRow);
+ int __maskPixel = __intVal(maskPixelValue);
+#ifdef DEBUG
+ unsigned char *outEnd;
+#endif
+
+ if (! __isByteArray(__INST(data))) goto fail;
+ if (! __isByteArray(maskArray)) goto fail;
+
+ __inP = __ByteArrayInstPtr(__INST(data))->ba_element;
+ __outP = __ByteArrayInstPtr(maskArray)->ba_element;
+
+#ifdef DEBUG
+ outEnd = __outP + (__byteArraySize(maskArray));
+#endif
+/*
+printf("outP: %x outEnd: %x sz: %d\n", __outP, outEnd, __byteArraySize(maskArray));
+*/
+
+ for (__y=__h; __y>0; __y--) {
+ __outBits = 0;
+ __nOut = 8;
+ __nextOutRow = __outP + __bpr;
+
+ for (__x=__w; __x>0; __x--) {
+ __outBits <<= 1;
+ if (*__inP != __maskPixel) {
+ __outBits |= 1;
+ }
+ __inP++;
+
+/*
+ printf("x: %d bits: %x\n", __x, __outBits);
+*/
+ if (--__nOut == 0) {
+#ifdef DEBUG
+ if (__outP >= outEnd) {
+ printf("oops\n");
+ goto fail;
+ }
+#endif
+ *__outP = __outBits;
+
+ __outP++;
+ __nOut = 8;
+ __outBits = 0;
+ }
+ }
+
+ if (__nOut != 8) {
+ __outBits <<= __nOut;
+
+#ifdef DEBUG
+ if (__outP >= outEnd) {
+ printf("oops2\n");
+ goto fail;
+ }
+#endif
+ *__outP = __outBits;
+
+ }
+ __outP = __nextOutRow;
+ }
+fail: ;
+%}.
+ mask := Depth1Image width:width height:height fromArray:maskArray.
+
+ "Created: 21.6.1996 / 11:43:47 / cg"
+
+!
+
fromStream:aStream
"read an image in my format from aStream.
Leave image description in instance variables."
@@ -1495,5 +1579,5 @@
!ImageReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.31 1996-06-21 09:54:17 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.32 1996-07-05 21:00:17 stefan Exp $'
! !