equal
deleted
inserted
replaced
1548 |
1548 |
1549 |t| |
1549 |t| |
1550 |
1550 |
1551 %{ /* OPTIONAL */ |
1551 %{ /* OPTIONAL */ |
1552 if (__isByteArray(data) && __isSmallInteger(nBytes)) { |
1552 if (__isByteArray(data) && __isSmallInteger(nBytes)) { |
1553 int __nBytes = __intVal(nBytes); |
1553 int __nBytes = __intVal(nBytes); |
1554 int __dataSize = __byteArraySize(data); |
1554 int __dataSize = __byteArraySize(data); |
1555 |
1555 |
1556 if (__nBytes <= __dataSize) { |
1556 if (__nBytes <= __dataSize) { |
1557 int __lastIndex = __nBytes - 2; |
1557 int __lastIndex = __nBytes - 2; |
1558 unsigned char *__cp = __ByteArrayInstPtr(data)->ba_element; |
1558 unsigned char *__cp = __ByteArrayInstPtr(data)->ba_element; |
1559 int __i; |
1559 int __i; |
1560 unsigned char __t; |
1560 unsigned char __t; |
1561 |
1561 |
1562 for (__i=0; __i<__lastIndex; __i+=3, __cp+=3) { |
1562 for (__i=0; __i<__lastIndex; __i+=3, __cp+=3) { |
1563 __t = __cp[0]; |
1563 __t = __cp[0]; |
1564 __cp[0] = __cp[2]; |
1564 __cp[0] = __cp[2]; |
1565 __cp[2] = __t; |
1565 __cp[2] = __t; |
1566 } |
1566 } |
1567 RETURN (true); |
1567 RETURN (true); |
1568 } |
1568 } |
1569 } |
1569 } |
1570 %}. |
1570 %}. |
1571 1 to:(nBytes - 2) by:3 do:[:i | |
1571 1 to:(nBytes - 2) by:3 do:[:i | |
1572 t := data at:i. |
1572 t := data at:i. |
1573 data at:i put:(data at:i+2). |
1573 data at:i put:(data at:i+2). |
1574 data at:i+2 put:t |
1574 data at:i+2 put:t |
1575 ]. |
1575 ]. |
1576 |
1576 |
1577 " |
1577 " |
1578 |bytes| |
1578 |bytes| |
1579 |
1579 |
1585 |bytes| |
1585 |bytes| |
1586 |
1586 |
1587 bytes := ByteArray new:1000000. |
1587 bytes := ByteArray new:1000000. |
1588 bytes replaceFrom:1 with:#[ 0 1 2 3 4 5 6 7 8 9 10 11 12]. |
1588 bytes replaceFrom:1 with:#[ 0 1 2 3 4 5 6 7 8 9 10 11 12]. |
1589 Time millisecondsToRun:[ |
1589 Time millisecondsToRun:[ |
1590 self swap:1000000 bytesFromRGB_to_BGR_in:bytes. |
1590 self swap:1000000 bytesFromRGB_to_BGR_in:bytes. |
1591 ]. |
1591 ]. |
1592 bytes copyTo:10. |
1592 bytes copyTo:10. |
1593 " |
1593 " |
1594 ! ! |
1594 ! ! |
1595 |
1595 |
1635 ]. |
1635 ]. |
1636 ^ nil |
1636 ^ nil |
1637 |
1637 |
1638 " |
1638 " |
1639 XBMReader fromFile:'bitmaps/SBrowser.xbm' |
1639 XBMReader fromFile:'bitmaps/SBrowser.xbm' |
1640 XPMReader fromFile:'bitmaps/xpmBitmaps/BOOK.xpm' |
1640 XPMReader fromFile:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm' |
1641 XBMReader fromFile:'bitmaps/xpmBitmaps/BOOK.xpm' |
1641 XBMReader fromFile:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm' |
1642 " |
1642 " |
1643 |
1643 |
1644 "Modified: 4.4.1997 / 22:09:49 / cg" |
1644 "Modified: 4.4.1997 / 22:09:49 / cg" |
1645 ! |
1645 ! |
1646 |
1646 |
1693 |
1693 |
1694 |reader inStream| |
1694 |reader inStream| |
1695 |
1695 |
1696 inStream := self streamReadingFile:aFileName. |
1696 inStream := self streamReadingFile:aFileName. |
1697 inStream isNil ifTrue:[ |
1697 inStream isNil ifTrue:[ |
1698 'ImageReader [warning]: file open error' errorPrintCR. |
1698 'ImageReader [warning]: file open error' errorPrintCR. |
1699 ^ nil |
1699 ^ nil |
1700 ]. |
1700 ]. |
1701 reader := self new. |
1701 reader := self new. |
1702 reader inStream:inStream. |
1702 reader inStream:inStream. |
1703 [ |
1703 [ |
1704 reader fromStream:inStream. |
1704 reader fromStream:inStream. |
1705 ] ensure:[ |
1705 ] ensure:[ |
1706 inStream close. |
1706 inStream close. |
1707 ]. |
1707 ]. |
1708 ^ reader |
1708 ^ reader |
1709 |
1709 |
1710 " |
1710 " |
1711 XPMReader readFile:'bitmaps/xpmBitmaps/BOOK.xpm' |
1711 XPMReader readFile:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm' |
1712 " |
1712 " |
1713 |
1713 |
1714 "Modified: 4.4.1997 / 22:06:49 / cg" |
1714 "Modified: 4.4.1997 / 22:06:49 / cg" |
1715 ! |
1715 ! |
1716 |
1716 |
1813 __outBits <<= __nOut; |
1813 __outBits <<= __nOut; |
1814 |
1814 |
1815 #ifdef DEBUG |
1815 #ifdef DEBUG |
1816 if (__outP >= outEnd) { |
1816 if (__outP >= outEnd) { |
1817 fprintf(stderr, "oops2 %d\n", __LINE__); |
1817 fprintf(stderr, "oops2 %d\n", __LINE__); |
1818 goto fail; |
1818 goto fail; |
1819 } |
1819 } |
1820 #endif |
1820 #endif |
1821 *__outP = __outBits; |
1821 *__outP = __outBits; |
1822 |
1822 |
1823 } |
1823 } |
1992 |
1992 |
1993 |image depth| |
1993 |image depth| |
1994 |
1994 |
1995 depth := self bitsPerPixel. |
1995 depth := self bitsPerPixel. |
1996 (depth notNil and:[data notNil]) ifTrue:[ |
1996 (depth notNil and:[data notNil]) ifTrue:[ |
1997 image := Image newForDepth:depth. |
1997 image := Image newForDepth:depth. |
1998 image depth:depth. |
1998 image depth:depth. |
1999 inStream isFileStream ifTrue:[ |
1999 inStream isFileStream ifTrue:[ |
2000 image fileName:inStream pathName. |
2000 image fileName:inStream pathName. |
2001 ]. |
2001 ]. |
2002 image |
2002 image |
2003 width:width |
2003 width:width |
2004 height:height |
2004 height:height |
2005 photometric:photometric |
2005 photometric:photometric |
2006 samplesPerPixel:samplesPerPixel |
2006 samplesPerPixel:samplesPerPixel |
2007 bitsPerSample:bitsPerSample |
2007 bitsPerSample:bitsPerSample |
2008 colorMap:colorMap |
2008 colorMap:colorMap |
2009 bits:data |
2009 bits:data |
2010 mask:mask. |
2010 mask:mask. |
2011 |
2011 |
2012 imageSequence notNil ifTrue:[ |
2012 imageSequence notNil ifTrue:[ |
2013 image imageSequence:imageSequence. |
2013 image imageSequence:imageSequence. |
2014 ]. |
2014 ]. |
2015 ]. |
2015 ]. |
2016 ^ image |
2016 ^ image |
2017 |
2017 |
2018 "Modified: / 15.1.1998 / 15:46:24 / stefan" |
2018 "Modified: / 15.1.1998 / 15:46:24 / stefan" |
2019 "Created: / 1.4.1998 / 14:09:45 / cg" |
2019 "Created: / 1.4.1998 / 14:09:45 / cg" |
2188 "save image in my format on aFile" |
2188 "save image in my format on aFile" |
2189 |
2189 |
2190 |stream| |
2190 |stream| |
2191 |
2191 |
2192 [ |
2192 [ |
2193 stream := aFileName asFilename newReadWriteStream. |
2193 stream := aFileName asFilename newReadWriteStream. |
2194 ] on:FileStream openErrorSignal do:[:ex| |
2194 ] on:FileStream openErrorSignal do:[:ex| |
2195 ^ Image fileCreationErrorSignal |
2195 ^ Image fileCreationErrorSignal |
2196 raiseWith:image |
2196 raiseWith:image |
2197 errorString:('file creation error: ' , aFileName asString). |
2197 errorString:('file creation error: ' , aFileName asString). |
2198 ]. |
2198 ]. |
2199 |
2199 |
2200 [ |
2200 [ |
2201 [ |
2201 [ |
2202 self save:image onStream:stream. |
2202 self save:image onStream:stream. |
2203 ] ifCurtailed:[ |
2203 ] ifCurtailed:[ |
2204 aFileName asFilename delete. |
2204 aFileName asFilename delete. |
2205 ]. |
2205 ]. |
2206 |
2206 |
2207 ] ensure:[ |
2207 ] ensure:[ |
2208 stream close. |
2208 stream close. |
2209 ]. |
2209 ]. |
2210 ! |
2210 ! |
2211 |
2211 |
2212 save:image onStream:aStream |
2212 save:image onStream:aStream |
2213 "save image in my format on a Stream" |
2213 "save image in my format on a Stream" |
2214 |
2214 |
2215 ^ Image cannotRepresentImageSignal |
2215 ^ Image cannotRepresentImageSignal |
2216 raiseWith:image |
2216 raiseWith:image |
2217 errorString:('image save not implemented for this format'). |
2217 errorString:('image save not implemented for this format'). |
2218 ! ! |
2218 ! ! |
2219 |
2219 |
2220 !ImageReader methodsFor:'initialization'! |
2220 !ImageReader methodsFor:'initialization'! |
2221 |
2221 |
2222 initialize |
2222 initialize |
2254 progressHolder := aValueHolderOrBlock |
2254 progressHolder := aValueHolderOrBlock |
2255 ! |
2255 ! |
2256 |
2256 |
2257 reportDimension |
2257 reportDimension |
2258 dimensionCallBack notNil ifTrue:[ |
2258 dimensionCallBack notNil ifTrue:[ |
2259 dimensionCallBack value:self |
2259 dimensionCallBack value:self |
2260 ]. |
2260 ]. |
2261 dimensionHolder notNil ifTrue:[ |
2261 dimensionHolder notNil ifTrue:[ |
2262 dimensionHolder value:(width @ height) |
2262 dimensionHolder value:(width @ height) |
2263 ]. |
2263 ]. |
2264 ! |
2264 ! |
2265 |
2265 |
2266 reportProgress:fraction |
2266 reportProgress:fraction |
2267 "can be used by a GUI application to indicate loading progress (0..1)" |
2267 "can be used by a GUI application to indicate loading progress (0..1)" |
2268 |
2268 |
2269 progressHolder notNil ifTrue:[ |
2269 progressHolder notNil ifTrue:[ |
2270 progressHolder value:fraction |
2270 progressHolder value:fraction |
2271 ]. |
2271 ]. |
2272 ! ! |
2272 ! ! |
2273 |
2273 |
2274 !ImageReader class methodsFor:'documentation'! |
2274 !ImageReader class methodsFor:'documentation'! |
2275 |
2275 |
2276 version |
2276 version |
2277 ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.86 2003-11-26 22:14:38 cg Exp $' |
2277 ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.87 2004-02-24 10:35:25 cg Exp $' |
2278 ! ! |
2278 ! ! |