equal
deleted
inserted
replaced
1543 ! ! |
1543 ! ! |
1544 |
1544 |
1545 !TIFFReader methodsFor:'private-reading'! |
1545 !TIFFReader methodsFor:'private-reading'! |
1546 |
1546 |
1547 positionToStrip:stripNr |
1547 positionToStrip:stripNr |
1548 inStream position0Based:(stripOffsets at:stripNr). |
1548 inStream position:(stripOffsets at:stripNr). |
1549 ! |
1549 ! |
1550 |
1550 |
1551 readBytes:n signed:isSigned |
1551 readBytes:n signed:isSigned |
1552 "read n 8bit signed or unsigned integers and return them in an array or byteArray" |
1552 "read n 8bit signed or unsigned integers and return them in an array or byteArray" |
1553 |
1553 |
1566 inStream skip:(4 - n). |
1566 inStream skip:(4 - n). |
1567 ] |
1567 ] |
1568 ] ifFalse:[ |
1568 ] ifFalse:[ |
1569 offset := inStream nextLongMSB:(byteOrder ~~ #lsb). |
1569 offset := inStream nextLongMSB:(byteOrder ~~ #lsb). |
1570 oldPos := inStream position. |
1570 oldPos := inStream position. |
1571 inStream position0Based:offset. |
1571 inStream position:offset. |
1572 isSigned ifTrue:[ |
1572 isSigned ifTrue:[ |
1573 1 to:n do:[:i | bytes at:i put:(inStream nextSignedByte) ]. |
1573 1 to:n do:[:i | bytes at:i put:(inStream nextSignedByte) ]. |
1574 ] ifFalse:[ |
1574 ] ifFalse:[ |
1575 inStream nextBytes:n into:bytes. |
1575 inStream nextBytes:n into:bytes. |
1576 ]. |
1576 ]. |
1593 inStream skip:(4 - n). |
1593 inStream skip:(4 - n). |
1594 ] |
1594 ] |
1595 ] ifFalse:[ |
1595 ] ifFalse:[ |
1596 offset := inStream nextLongMSB:(byteOrder ~~ #lsb). |
1596 offset := inStream nextLongMSB:(byteOrder ~~ #lsb). |
1597 oldPos := inStream position. |
1597 oldPos := inStream position. |
1598 inStream position0Based:offset. |
1598 inStream position:offset. |
1599 inStream nextBytes:(n - 1) into:string. |
1599 inStream nextBytes:(n - 1) into:string. |
1600 inStream position:oldPos |
1600 inStream position:oldPos |
1601 ]. |
1601 ]. |
1602 ^ string |
1602 ^ string |
1603 |
1603 |
1618 val := Float readBinaryIEEEDoubleFrom:inStream MSB:msb. |
1618 val := Float readBinaryIEEEDoubleFrom:inStream MSB:msb. |
1619 values at:1 put:val. |
1619 values at:1 put:val. |
1620 ] ifFalse:[ |
1620 ] ifFalse:[ |
1621 offset := inStream nextLongMSB:msb. |
1621 offset := inStream nextLongMSB:msb. |
1622 oldPos := inStream position. |
1622 oldPos := inStream position. |
1623 inStream position0Based:offset. |
1623 inStream position:offset. |
1624 1 to:n do:[:index | |
1624 1 to:n do:[:index | |
1625 val := Float readBinaryIEEEDoubleFrom:inStream MSB:msb. |
1625 val := Float readBinaryIEEEDoubleFrom:inStream MSB:msb. |
1626 values at:index put:val |
1626 values at:index put:val |
1627 ]. |
1627 ]. |
1628 inStream position:oldPos |
1628 inStream position:oldPos |
1644 val := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
1644 val := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
1645 values at:1 put:val. |
1645 values at:1 put:val. |
1646 ] ifFalse:[ |
1646 ] ifFalse:[ |
1647 offset := inStream nextLongMSB:msb. |
1647 offset := inStream nextLongMSB:msb. |
1648 oldPos := inStream position. |
1648 oldPos := inStream position. |
1649 inStream position0Based:offset. |
1649 inStream position:offset. |
1650 1 to:n do:[:index | |
1650 1 to:n do:[:index | |
1651 val := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
1651 val := ShortFloat readBinaryIEEESingleFrom:inStream MSB:msb. |
1652 values at:index put:val |
1652 values at:index put:val |
1653 ]. |
1653 ]. |
1654 inStream position:oldPos |
1654 inStream position:oldPos |
1666 |
1666 |
1667 msb := byteOrder ~~ #lsb. |
1667 msb := byteOrder ~~ #lsb. |
1668 values := Array basicNew:n. |
1668 values := Array basicNew:n. |
1669 offset := inStream nextLongMSB:msb. |
1669 offset := inStream nextLongMSB:msb. |
1670 oldPos := inStream position. |
1670 oldPos := inStream position. |
1671 inStream position0Based:offset. |
1671 inStream position:offset. |
1672 1 to:n do:[:index | |
1672 1 to:n do:[:index | |
1673 numerator := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1673 numerator := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1674 denominator := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1674 denominator := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1675 values at:index put:(Fraction numerator:numerator denominator:denominator) |
1675 values at:index put:(Fraction numerator:numerator denominator:denominator) |
1676 ]. |
1676 ]. |
1692 val := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1692 val := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1693 values at:1 put:val. |
1693 values at:1 put:val. |
1694 ] ifFalse:[ |
1694 ] ifFalse:[ |
1695 offset := inStream nextLongMSB:msb. |
1695 offset := inStream nextLongMSB:msb. |
1696 oldPos := inStream position. |
1696 oldPos := inStream position. |
1697 inStream position0Based:offset. |
1697 inStream position:offset. |
1698 1 to:n do:[:index | |
1698 1 to:n do:[:index | |
1699 val := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1699 val := isSigned ifTrue:[inStream nextLongMSB:msb] ifFalse:[inStream nextUnsignedLongMSB:msb]. |
1700 values at:index put:val |
1700 values at:index put:val |
1701 ]. |
1701 ]. |
1702 inStream position:oldPos |
1702 inStream position:oldPos |
1727 values at:2 put:val2 |
1727 values at:2 put:val2 |
1728 ] |
1728 ] |
1729 ] ifFalse:[ |
1729 ] ifFalse:[ |
1730 offset := inStream nextLongMSB:msb. |
1730 offset := inStream nextLongMSB:msb. |
1731 oldPos := inStream position. |
1731 oldPos := inStream position. |
1732 inStream position0Based:offset. |
1732 inStream position:offset. |
1733 1 to:n do:[:index | |
1733 1 to:n do:[:index | |
1734 isSigned ifTrue:[ |
1734 isSigned ifTrue:[ |
1735 val1 := inStream nextShortMSB:msb. |
1735 val1 := inStream nextShortMSB:msb. |
1736 ] ifFalse:[ |
1736 ] ifFalse:[ |
1737 val1 := inStream nextUnsignedShortMSB:msb. |
1737 val1 := inStream nextUnsignedShortMSB:msb. |
1748 writeBitsPerSample |
1748 writeBitsPerSample |
1749 " |
1749 " |
1750 'bitsPerSample: ' print. bitsPerSample printNewline. |
1750 'bitsPerSample: ' print. bitsPerSample printNewline. |
1751 'store bitspersample at: ' print. outStream position printNewline. |
1751 'store bitspersample at: ' print. outStream position printNewline. |
1752 " |
1752 " |
1753 bitsPerSamplePos := outStream position0Based. |
1753 bitsPerSamplePos := outStream position. |
1754 bitsPerSample do:[:n | |
1754 bitsPerSample do:[:n | |
1755 self writeShort:n |
1755 self writeShort:n |
1756 ] |
1756 ] |
1757 ! |
1757 ! |
1758 |
1758 |
1759 writeColorMap |
1759 writeColorMap |
1760 |n| |
1760 |n| |
1761 |
1761 |
1762 colorMapPos := outStream position0Based. |
1762 colorMapPos := outStream position. |
1763 #(red green blue) do:[:component | |
1763 #(red green blue) do:[:component | |
1764 n := 0. |
1764 n := 0. |
1765 colorMap do:[:clr | |
1765 colorMap do:[:clr | |
1766 |entry| |
1766 |entry| |
1767 |
1767 |
1793 writeStripByteCounts |
1793 writeStripByteCounts |
1794 " |
1794 " |
1795 'stripByteCounts: ' print. stripByteCounts printNewline. |
1795 'stripByteCounts: ' print. stripByteCounts printNewline. |
1796 'store stripbytecounts at: ' print. outStream position printNewline. |
1796 'store stripbytecounts at: ' print. outStream position printNewline. |
1797 " |
1797 " |
1798 stripByteCountsPos := outStream position0Based. |
1798 stripByteCountsPos := outStream position. |
1799 stripByteCounts do:[:c | |
1799 stripByteCounts do:[:c | |
1800 self writeShort:c |
1800 self writeShort:c |
1801 ] |
1801 ] |
1802 ! |
1802 ! |
1803 |
1803 |
1804 writeStripOffsets |
1804 writeStripOffsets |
1805 " |
1805 " |
1806 'stripOffsets: ' print. stripOffsets printNewline. |
1806 'stripOffsets: ' print. stripOffsets printNewline. |
1807 'store stripoffsets at: ' print. outStream position printNewline. |
1807 'store stripoffsets at: ' print. outStream position printNewline. |
1808 " |
1808 " |
1809 stripOffsetsPos := outStream position0Based. |
1809 stripOffsetsPos := outStream position. |
1810 stripOffsets do:[:o | |
1810 stripOffsets do:[:o | |
1811 self writeLong:o |
1811 self writeLong:o |
1812 ] |
1812 ] |
1813 ! |
1813 ! |
1814 |
1814 |
2095 |offs bytesPerRow nBytes |
2095 |offs bytesPerRow nBytes |
2096 h "{ Class: SmallInteger }"| |
2096 h "{ Class: SmallInteger }"| |
2097 |
2097 |
2098 nBytes := data size. |
2098 nBytes := data size. |
2099 nBytes < 16rFFFF ifTrue:[ |
2099 nBytes < 16rFFFF ifTrue:[ |
2100 stripOffsets := Array with:(outStream position0Based). |
2100 stripOffsets := Array with:(outStream position). |
2101 stripByteCounts := Array with:nBytes. |
2101 stripByteCounts := Array with:nBytes. |
2102 outStream nextPutBytes:nBytes from:data. |
2102 outStream nextPutBytes:nBytes from:data. |
2103 rowsPerStrip := height |
2103 rowsPerStrip := height |
2104 ] ifFalse:[ |
2104 ] ifFalse:[ |
2105 stripOffsets := Array basicNew:height. |
2105 stripOffsets := Array basicNew:height. |
2107 stripByteCounts := (Array basicNew:height) atAllPut:bytesPerRow. |
2107 stripByteCounts := (Array basicNew:height) atAllPut:bytesPerRow. |
2108 |
2108 |
2109 offs := 1. |
2109 offs := 1. |
2110 h := height. |
2110 h := height. |
2111 1 to:h do:[:row | |
2111 1 to:h do:[:row | |
2112 stripOffsets at:row put:(outStream position0Based). |
2112 stripOffsets at:row put:(outStream position). |
2113 outStream nextPutBytes:bytesPerRow from:data startingAt:offs. |
2113 outStream nextPutBytes:bytesPerRow from:data startingAt:offs. |
2114 offs := offs + bytesPerRow |
2114 offs := offs + bytesPerRow |
2115 ]. |
2115 ]. |
2116 rowsPerStrip := 1 |
2116 rowsPerStrip := 1 |
2117 ]. |
2117 ]. |
2175 "resolutionUnit := 2." |
2175 "resolutionUnit := 2." |
2176 predictor := 1. |
2176 predictor := 1. |
2177 orientation := nil. |
2177 orientation := nil. |
2178 |
2178 |
2179 offset := aStream nextLongMSB:msb. |
2179 offset := aStream nextLongMSB:msb. |
2180 aStream position0Based:offset. |
2180 aStream position:offset. |
2181 |
2181 |
2182 numberOfTags := self readShort. |
2182 numberOfTags := self readShort. |
2183 1 to:numberOfTags do:[:index | |
2183 1 to:numberOfTags do:[:index | |
2184 tagType := self readShort. |
2184 tagType := self readShort. |
2185 numberType := self readShort. |
2185 numberType := self readShort. |
2319 self writeBitsPerSample. "this outputs bitsPerSample, sets bitsPerSamplePos" |
2319 self writeBitsPerSample. "this outputs bitsPerSample, sets bitsPerSamplePos" |
2320 photometric == #palette ifTrue:[ |
2320 photometric == #palette ifTrue:[ |
2321 self writeColorMap "this outputs colorMap, sets colorMapPos" |
2321 self writeColorMap "this outputs colorMap, sets colorMapPos" |
2322 ]. |
2322 ]. |
2323 |
2323 |
2324 pos := outStream position0Based. "backpatch tag offset" |
2324 pos := outStream position. "backpatch tag offset" |
2325 outStream position:pos1. |
2325 outStream position:pos1. |
2326 self writeLong:pos. "fill in tag offset" |
2326 self writeLong:pos. "fill in tag offset" |
2327 outStream position0Based:pos. |
2327 outStream position:pos. |
2328 " |
2328 " |
2329 ('patch tag offset at: ', (pos1 printStringRadix:16) , ' to ', |
2329 ('patch tag offset at: ', (pos1 printStringRadix:16) , ' to ', |
2330 (pos printStringRadix:16)) printNewline. |
2330 (pos printStringRadix:16)) printNewline. |
2331 " |
2331 " |
2332 "output tag data" |
2332 "output tag data" |
2353 ! ! |
2353 ! ! |
2354 |
2354 |
2355 !TIFFReader class methodsFor:'documentation'! |
2355 !TIFFReader class methodsFor:'documentation'! |
2356 |
2356 |
2357 version |
2357 version |
2358 ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.84 2013-03-31 19:34:32 cg Exp $' |
2358 ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.85 2013-08-10 11:10:37 stefan Exp $' |
2359 ! ! |
2359 ! ! |
2360 |
2360 |
2361 |
2361 |
2362 TIFFReader initialize! |
2362 TIFFReader initialize! |