--- a/ImageReader.st Tue Feb 03 16:05:18 1998 +0100
+++ b/ImageReader.st Tue Feb 03 17:51:57 1998 +0100
@@ -1382,110 +1382,6 @@
"Modified: 22.4.1996 / 19:14:54 / cg"
! !
-!ImageReader class methodsFor:'image support'!
-
-buildMaskFromColor:maskPixelValue for:pixels width:width height:height
- "helper for image formats, where an individual pixel value
- has been defined as a mask-pixel (i.e. GIF).
- Creates a maskImage, with zeros at positions where the image
- has the given pixelValue; all other mask pixels are set to 1."
-
- |maskArray bytesPerMaskRow mask|
-
- bytesPerMaskRow := (width+7) // 8.
-
- maskArray := ByteArray uninitializedNew:bytesPerMaskRow * height.
-
-%{
- int __w = __intVal(width);
- int __h = __intVal(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(pixels)) goto fail;
- if (! __isByteArray(maskArray)) goto fail;
-
- __inP = __ByteArrayInstPtr(pixels)->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>=8; __x-=8) {
- if (__inP[0] != __maskPixel) { __outBits |= 0x80; };
- if (__inP[1] != __maskPixel) { __outBits |= 0x40; };
- if (__inP[2] != __maskPixel) { __outBits |= 0x20; };
- if (__inP[3] != __maskPixel) { __outBits |= 0x10; };
- if (__inP[4] != __maskPixel) { __outBits |= 0x08; };
- if (__inP[5] != __maskPixel) { __outBits |= 0x04; };
- if (__inP[6] != __maskPixel) { __outBits |= 0x02; };
- if (__inP[7] != __maskPixel) { __outBits |= 0x01; };
- __inP += 8;
- *__outP++ = __outBits;
- __outBits = 0;
- }
- for (; __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 := ImageMask width:width height:height fromArray:maskArray.
- ^ mask
-
- "Created: 21.6.1996 / 11:43:47 / cg"
-! !
-
!ImageReader class methodsFor:'i/o support'!
streamReadingFile:aFilename
@@ -1617,6 +1513,110 @@
"Created: 4.4.1997 / 22:08:13 / cg"
! !
+!ImageReader class methodsFor:'image support'!
+
+buildMaskFromColor:maskPixelValue for:pixels width:width height:height
+ "helper for image formats, where an individual pixel value
+ has been defined as a mask-pixel (i.e. GIF).
+ Creates a maskImage, with zeros at positions where the image
+ has the given pixelValue; all other mask pixels are set to 1."
+
+ |maskArray bytesPerMaskRow mask|
+
+ bytesPerMaskRow := (width+7) // 8.
+
+ maskArray := ByteArray uninitializedNew:bytesPerMaskRow * height.
+
+%{
+ int __w = __intVal(width);
+ int __h = __intVal(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(pixels)) goto fail;
+ if (! __isByteArray(maskArray)) goto fail;
+
+ __inP = __ByteArrayInstPtr(pixels)->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>=8; __x-=8) {
+ if (__inP[0] != __maskPixel) { __outBits |= 0x80; };
+ if (__inP[1] != __maskPixel) { __outBits |= 0x40; };
+ if (__inP[2] != __maskPixel) { __outBits |= 0x20; };
+ if (__inP[3] != __maskPixel) { __outBits |= 0x10; };
+ if (__inP[4] != __maskPixel) { __outBits |= 0x08; };
+ if (__inP[5] != __maskPixel) { __outBits |= 0x04; };
+ if (__inP[6] != __maskPixel) { __outBits |= 0x02; };
+ if (__inP[7] != __maskPixel) { __outBits |= 0x01; };
+ __inP += 8;
+ *__outP++ = __outBits;
+ __outBits = 0;
+ }
+ for (; __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 := ImageMask width:width height:height fromArray:maskArray.
+ ^ mask
+
+ "Created: 21.6.1996 / 11:43:47 / cg"
+! !
+
!ImageReader class methodsFor:'image writing'!
save:anImage onFile:aFileName
@@ -1849,6 +1849,19 @@
"Created: 15.2.1997 / 13:57:35 / cg"
! !
+!ImageReader methodsFor:'error reporting'!
+
+fileFormatError:aMessage
+ "report a format error - no image could be read"
+
+ Image
+ badImageFormatQuerySignal
+ raiseErrorString:(self class name , ' [info]: ' , aMessage).
+ ^ nil
+
+ "Created: / 3.2.1998 / 17:50:06 / cg"
+! !
+
!ImageReader methodsFor:'i/o support'!
readLong
@@ -1893,6 +1906,18 @@
outStream nextPutShort:anInteger MSB:(byteOrder ~~ #lsb)
! !
+!ImageReader methodsFor:'image reading'!
+
+fromStream:aStream
+ "read an image in my format from aStream.
+ Leave image description in instance variables."
+
+
+ ^ self subclassResponsibility
+
+ "Modified: 22.4.1996 / 19:11:31 / cg"
+! !
+
!ImageReader methodsFor:'image reading support'!
buildMaskFromColor:maskPixelValue
@@ -1910,18 +1935,6 @@
"Modified: / 14.1.1998 / 14:48:33 / cg"
! !
-!ImageReader methodsFor:'image reading'!
-
-fromStream:aStream
- "read an image in my format from aStream.
- Leave image description in instance variables."
-
-
- ^ self subclassResponsibility
-
- "Modified: 22.4.1996 / 19:11:31 / cg"
-! !
-
!ImageReader methodsFor:'image writing'!
save:image onFile:aFileName
@@ -1944,5 +1957,5 @@
!ImageReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.59 1998-01-25 14:12:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.60 1998-02-03 16:51:57 cg Exp $'
! !