TIFFReader.st
changeset 159 327da5085900
parent 135 ff507d9a242b
child 192 947cc10f86dc
equal deleted inserted replaced
158:16f2237474fe 159:327da5085900
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 ImageReader subclass:#TIFFReader
    13 ImageReader subclass:#TIFFReader
    14 	 instanceVariableNames:'planarConfiguration subFileType stripOffsets rowsPerStrip
    14 	 instanceVariableNames:'planarConfiguration subFileType stripOffsets rowsPerStrip
    15                 fillOrder compression group3options predictor stripByteCounts
    15 		fillOrder compression group3options predictor stripByteCounts
    16                 currentOffset stripOffsetsPos stripByteCountsPos bitsPerSamplePos
    16 		currentOffset stripOffsetsPos stripByteCountsPos bitsPerSamplePos
    17                 colorMapPos'
    17 		colorMapPos'
    18 	 classVariableNames:''
    18 	 classVariableNames:''
    19 	 poolDictionaries:''
    19 	 poolDictionaries:''
    20 	 category:'Graphics-Images support'
    20 	 category:'Graphics-Images support'
    21 !
    21 !
    22 
    22 
    41     This class knows how to read TIFF files and how to
    41     This class knows how to read TIFF files and how to
    42     write uncompressed TIFF files.
    42     write uncompressed TIFF files.
    43 
    43 
    44     Only single image files are supported.
    44     Only single image files are supported.
    45     Not all formats are implemented, and of those that are, not all are tested.
    45     Not all formats are implemented, and of those that are, not all are tested.
    46     It should work with most rgb, mono and 2-plane greyscale
    46     It should read with most rgb, mono and 2-plane greyscale
    47     images, since this is what I have as test material on the NeXT.
    47     images, since this is what I have as test material on the NeXT.
    48     It supports reading of uncompressed, LZW and G3 compressed 
    48     It supports reading of uncompressed, LZW and G3 compressed 
    49     images; JPEG and packbits are currently not implemented.
    49     images; JPEG and packbits are currently not implemented.
    50 
    50 
    51     Only writing of uncompressed images is currently implemented.
    51     Only writing of uncompressed images is currently implemented.
       
    52     It should write (at least) mono, 8-bit palette and 24 bit rgb formats.
    52     More formats will come ...
    53     More formats will come ...
    53 
    54 
    54     TODO: since I dont want to spend all of my life adding more formats here and
    55     TODO: since I dont want to spend all of my life adding more formats here and
    55     reinventing the wheel, this code should be changed to use the tiff library.
    56     reinventing the wheel, this code should be changed to use the tiff library.
    56     That would give us most formats and also writing capabilities for free.
    57     That would give us most formats and also writing capabilities for free.
  1567     data := image bits.
  1568     data := image bits.
  1568 
  1569 
  1569     currentOffset := 0.
  1570     currentOffset := 0.
  1570 
  1571 
  1571     (byteOrder == #msb) ifTrue:[
  1572     (byteOrder == #msb) ifTrue:[
  1572 	outStream nextPut:$M.
  1573 	outStream nextPut:$M. outStream nextPut:$M.
  1573 	outStream nextPut:$M.
       
  1574     ] ifFalse:[
  1574     ] ifFalse:[
  1575 	outStream nextPut:$I.
  1575 	outStream nextPut:$I. outStream nextPut:$I.
  1576 	outStream nextPut:$I.
       
  1577     ].
  1576     ].
  1578     currentOffset := currentOffset + 2.
  1577     currentOffset := currentOffset + 2.
  1579 
  1578 
  1580     outStream binary.
  1579     outStream binary.
  1581 
  1580 
  1605 			 (pos printStringRadix:16)) printNewline.
  1604 			 (pos printStringRadix:16)) printNewline.
  1606 "
  1605 "
  1607     "output tag data"
  1606     "output tag data"
  1608 
  1607 
  1609     photometric == #palette ifTrue:[
  1608     photometric == #palette ifTrue:[
       
  1609 	self writeShort:11.  "11 tags"
       
  1610     ] ifFalse:[
  1610 	self writeShort:10.  "10 tags"
  1611 	self writeShort:10.  "10 tags"
  1611     ] ifFalse:[
       
  1612 	self writeShort:9.   "9 tags"
       
  1613     ].
  1612     ].
  1614     self writeTag:256.               "image width"
  1613     self writeTag:256.               "image width"
  1615     self writeTag:257.               "image height"
  1614     self writeTag:257.               "image height"
  1616     self writeTag:258.               "bits per sample"
  1615     self writeTag:258.               "bits per sample"
  1617     self writeTag:259.               "compression"
  1616     self writeTag:259.               "compression"
  1618     self writeTag:262.               "photometric"
  1617     self writeTag:262.               "photometric"
  1619     self writeTag:273.               "strip offsets"
  1618     self writeTag:273.               "strip offsets"
       
  1619     self writeTag:277.               "samplesPerPixel"
  1620     self writeTag:278.               "rowsPerStrip"
  1620     self writeTag:278.               "rowsPerStrip"
  1621     self writeTag:279.               "strip byte counts"
  1621     self writeTag:279.               "strip byte counts"
  1622     self writeTag:284.               "planarconfig"
  1622     self writeTag:284.               "planarconfig"
  1623     photometric == #palette ifTrue:[
  1623     photometric == #palette ifTrue:[
  1624 	self writeTag:320            "colorMap"
  1624 	self writeTag:320            "colorMap"
  1628 ! !
  1628 ! !
  1629 
  1629 
  1630 !TIFFReader class methodsFor:'documentation'!
  1630 !TIFFReader class methodsFor:'documentation'!
  1631 
  1631 
  1632 version
  1632 version
  1633     ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.27 1995-12-07 11:38:46 cg Exp $'
  1633     ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.28 1996-02-04 15:35:54 cg Exp $'
  1634 ! !
  1634 ! !
  1635 TIFFReader initialize!
  1635 TIFFReader initialize!