ImageReader.st
changeset 1772 56b3ae478bbb
parent 1661 5b4c1f6ab871
child 1773 e12d18fb2b4c
equal deleted inserted replaced
1771:ee831cb59127 1772:56b3ae478bbb
    11 "
    11 "
    12 
    12 
    13 Object subclass:#ImageReader
    13 Object subclass:#ImageReader
    14 	instanceVariableNames:'width height data byteOrder inStream outStream photometric
    14 	instanceVariableNames:'width height data byteOrder inStream outStream photometric
    15 		samplesPerPixel bitsPerSample colorMap mask maskPixel
    15 		samplesPerPixel bitsPerSample colorMap mask maskPixel
    16 		dimensionCallBack'
    16 		dimensionCallBack imageSequence'
    17 	classVariableNames:'ReverseBits'
    17 	classVariableNames:'ReverseBits'
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Graphics-Images-Support'
    19 	category:'Graphics-Images-Support'
    20 !
    20 !
    21 
    21 
  1541 
  1541 
  1542     "Created: 14.9.1996 / 17:10:58 / cg"
  1542     "Created: 14.9.1996 / 17:10:58 / cg"
  1543 !
  1543 !
  1544 
  1544 
  1545 hasMultipleImages
  1545 hasMultipleImages
  1546     ^ false
  1546     ^ self numberOfImages > 1
  1547 
  1547 
  1548     "Created: 4.4.1997 / 21:37:06 / cg"
  1548     "Created: 4.4.1997 / 21:37:06 / cg"
       
  1549     "Modified: 21.6.1997 / 18:34:24 / cg"
  1549 !
  1550 !
  1550 
  1551 
  1551 height 
  1552 height 
  1552     "return the height of the image"
  1553     "return the height of the image"
  1553 
  1554 
  1555 
  1556 
  1556     "Modified: 22.4.1996 / 19:15:39 / cg"
  1557     "Modified: 22.4.1996 / 19:15:39 / cg"
  1557 !
  1558 !
  1558 
  1559 
  1559 image
  1560 image
  1560     "return the image as represented by myself"
  1561     "return the image as represented by myself;
       
  1562      If my file contained multiple images, return the first one."
  1561 
  1563 
  1562     |image depth|
  1564     |image depth|
       
  1565 
       
  1566     self hasMultipleImages ifTrue:[
       
  1567         ^ self images first
       
  1568     ].
  1563 
  1569 
  1564     depth := self bitsPerPixel.
  1570     depth := self bitsPerPixel.
  1565     image := (Image implementorForDepth:depth) new.
  1571     image := (Image implementorForDepth:depth) new.
  1566     image depth:depth.
  1572     image depth:depth.
  1567     image 
  1573     image 
  1573         colorMap:colorMap
  1579         colorMap:colorMap
  1574         bits:data
  1580         bits:data
  1575         mask:mask.
  1581         mask:mask.
  1576     ^ image
  1582     ^ image
  1577 
  1583 
  1578     "Modified: 24.4.1997 / 14:28:04 / cg"
  1584     "Modified: 21.6.1997 / 18:32:27 / cg"
  1579 !
  1585 !
  1580 
  1586 
  1581 images
  1587 images
  1582     "return a collection of all images as represented by myself.
  1588     "return a collection of all images as represented by myself.
  1583      For compatibility with single-image formats, return a collection
  1589      For compatibility with single-image formats, return a collection
  1584      containing my single image here."
  1590      containing my single image here.
       
  1591      This must be redefined in readers for formats which support multiple
       
  1592      images in a single file."
  1585 
  1593 
  1586     |img|
  1594     |img|
  1587 
  1595 
  1588     img := self image.
  1596     img := self image.
  1589     img isNil ifTrue:[
  1597     img isNil ifTrue:[
  1590         ^ img
  1598         ^ img
  1591     ].
  1599     ].
  1592     ^ Array with:img
  1600     ^ Array with:img
  1593 
  1601 
  1594     "Modified: 4.4.1997 / 22:02:22 / cg"
  1602     "Modified: 21.6.1997 / 18:35:52 / cg"
  1595 !
  1603 !
  1596 
  1604 
  1597 mask
  1605 mask
  1598     "return the image mask (or nil)"
  1606     "return the image mask (or nil)"
  1599 
  1607 
  1600     ^ mask
  1608     ^ mask
  1601 
  1609 
  1602     "Modified: 22.4.1996 / 19:15:31 / cg"
  1610     "Modified: 22.4.1996 / 19:15:31 / cg"
  1603     "Created: 20.6.1996 / 17:08:29 / cg"
  1611     "Created: 20.6.1996 / 17:08:29 / cg"
       
  1612 !
       
  1613 
       
  1614 numberOfImages
       
  1615     "return the number of images as read.
       
  1616      By default (here), I hold a single image;
       
  1617      however, some fileFormats allow for multiple images"
       
  1618 
       
  1619     ^ 1
       
  1620 
       
  1621     "Created: 21.6.1997 / 18:33:45 / cg"
       
  1622     "Modified: 21.6.1997 / 18:35:19 / cg"
  1604 !
  1623 !
  1605 
  1624 
  1606 photometric
  1625 photometric
  1607     "return the photometric interpretation of the image data"
  1626     "return the photometric interpretation of the image data"
  1608 
  1627 
  1814 ! !
  1833 ! !
  1815 
  1834 
  1816 !ImageReader class methodsFor:'documentation'!
  1835 !ImageReader class methodsFor:'documentation'!
  1817 
  1836 
  1818 version
  1837 version
  1819     ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.48 1997-04-24 16:09:06 cg Exp $'
  1838     ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.49 1997-06-24 13:29:26 cg Exp $'
  1820 ! !
  1839 ! !