TIFFReader.st
changeset 3985 3d9f0b1a06d0
parent 3984 e533a09c2c1d
child 3986 a71704884650
equal deleted inserted replaced
3984:e533a09c2c1d 3985:3d9f0b1a06d0
  1183                 ^ self fileFormatError:'only 8/8/8 rgb images supported'.
  1183                 ^ self fileFormatError:'only 8/8/8 rgb images supported'.
  1184             ].
  1184             ].
  1185             bitsPerPixel := 24
  1185             bitsPerPixel := 24
  1186         ] ifFalse:[
  1186         ] ifFalse:[
  1187             (nPlanes ~~ 1) ifTrue:[
  1187             (nPlanes ~~ 1) ifTrue:[
  1188                 ^ self fileFormatError:'format not supported'.
  1188                 ^ self fileFormatError:('format (nplanes == %1) not supported' bindWith:nPlanes).
  1189             ].
  1189             ].
  1190             bitsPerPixel := bitsPerSample at:1.
  1190             bitsPerPixel := bitsPerSample at:1.
  1191         ]
  1191         ]
  1192     ].
  1192     ].
  1193     stripRowCounts notNil ifTrue:[
  1193     stripRowCounts notNil ifTrue:[
  1229         offset := offset + (bytesPerRow * rowsPerStrip).
  1229         offset := offset + (bytesPerRow * rowsPerStrip).
  1230         row := row + rowsPerStrip.
  1230         row := row + rowsPerStrip.
  1231         stripNr := stripNr + 1.
  1231         stripNr := stripNr + 1.
  1232     ]
  1232     ]
  1233 
  1233 
  1234     "Modified: / 27-08-2017 / 15:38:37 / cg"
  1234     "Modified: / 27-08-2017 / 21:28:46 / cg"
  1235 !
  1235 !
  1236 
  1236 
  1237 readPixarFilmTiffImageData
  1237 readPixarFilmTiffImageData
  1238     ^ self fileFormatError:'pixar film compression not implemented'.
  1238     ^ self fileFormatError:'pixar film compression not implemented'.
  1239 
  1239 
  1525     "Created: / 25-08-2017 / 00:19:14 / cg"
  1525     "Created: / 25-08-2017 / 00:19:14 / cg"
  1526     "Modified: / 26-08-2017 / 13:39:15 / cg"
  1526     "Modified: / 26-08-2017 / 13:39:15 / cg"
  1527 !
  1527 !
  1528 
  1528 
  1529 readTiledUncompressedTiffImageData
  1529 readTiledUncompressedTiffImageData
  1530     |bytesPerRow   "{ Class: SmallInteger }"
  1530     |bytesPerRow     "{ Class: SmallInteger }"
  1531      bitsPerRow    "{ Class: SmallInteger }"
  1531      bitsPerRow      "{ Class: SmallInteger }"
  1532      bytesPerTileRow   "{ Class: SmallInteger }"
  1532      bytesPerTileRow "{ Class: SmallInteger }"
  1533      bitsPerTileRow    "{ Class: SmallInteger }" 
  1533      bitsPerTileRow  "{ Class: SmallInteger }" 
  1534      nPlanes 
  1534      nPlanes 
  1535      tileNr        "{ Class: SmallInteger }"
  1535      tileNr          "{ Class: SmallInteger }"
  1536      offset        "{ Class: SmallInteger }"
  1536      "/ offset          "{ Class: SmallInteger }"
  1537      row           "{ Class: SmallInteger }" 
  1537      "/ row             "{ Class: SmallInteger }" 
  1538      nBytes        "{ Class: SmallInteger }"
  1538      nBytes          "{ Class: SmallInteger }"
  1539      bitsPerPixel 
  1539      bitsPerPixel    "{ Class: SmallInteger }"
  1540      overAllBytes  "{ Class: SmallInteger }"
  1540      overAllBytes    "{ Class: SmallInteger }"
  1541      where         "{ Class: SmallInteger }"
  1541      where           "{ Class: SmallInteger }"
  1542      x             "{ Class: SmallInteger }"       
  1542      x               "{ Class: SmallInteger }"       
  1543      y             "{ Class: SmallInteger }" 
  1543      y               "{ Class: SmallInteger }" 
  1544      imageRowOffset  "{ Class: SmallInteger }" 
  1544      imageRowOffset  "{ Class: SmallInteger }" 
  1545      imageOffset     "{ Class: SmallInteger }" 
  1545      imageOffset     "{ Class: SmallInteger }" 
  1546      tileOffset      "{ Class: SmallInteger }"   
  1546      tileOffset      "{ Class: SmallInteger }"   
  1547      dataOffset      "{ Class: SmallInteger }"   
  1547      dataOffset      "{ Class: SmallInteger }"   
  1548      tilePos tile tH tW tb|
  1548      tilePos tile tH tW tb|
  1564         (nPlanes == 4) ifTrue:[
  1564         (nPlanes == 4) ifTrue:[
  1565             (planarConfiguration ~~ PLANARCONFIG_CONTIG) ifTrue:[
  1565             (planarConfiguration ~~ PLANARCONFIG_CONTIG) ifTrue:[
  1566                 ^ self fileFormatError:'only non separate planes supported'.
  1566                 ^ self fileFormatError:'only non separate planes supported'.
  1567             ].
  1567             ].
  1568             bitsPerSample ~= #(8 8 8 8) ifTrue:[
  1568             bitsPerSample ~= #(8 8 8 8) ifTrue:[
  1569                 ^ self fileFormatError:'only 8/8/8/8 cmyk images supported'.
  1569                 ^ self fileFormatError:'only 8/8/8/8 images supported (is: ' , bitsPerSample printString , ')'.
  1570             ].
  1570             ].
  1571             bitsPerPixel := 32.
  1571             bitsPerPixel := 32.
  1572         ] ifFalse:[
  1572         ] ifFalse:[
  1573             (nPlanes == 3) ifTrue:[
  1573             (nPlanes == 3) ifTrue:[
  1574                 (planarConfiguration ~~ PLANARCONFIG_CONTIG) ifTrue:[
  1574                 (planarConfiguration ~~ PLANARCONFIG_CONTIG) ifTrue:[
  1575                     ^ self fileFormatError:'only non separate planes supported'.
  1575                     ^ self fileFormatError:'only non separate planes supported'.
  1576                 ].
  1576                 ].
  1577                 bitsPerSample ~= #(8 8 8) ifTrue:[
  1577                 bitsPerSample ~= #(8 8 8) ifTrue:[
  1578                     ^ self fileFormatError:'only 8/8/8 rgb images supported (is: ' , bitsPerSample printString , ')'.
  1578                     ^ self fileFormatError:'only 8/8/8 images supported (is: ' , bitsPerSample printString , ')'.
  1579                 ].
  1579                 ].
  1580                 bitsPerPixel := 24
  1580                 bitsPerPixel := 24
  1581             ] ifFalse:[
  1581             ] ifFalse:[
  1582                 (nPlanes ~~ 1) ifTrue:[
  1582                 (nPlanes ~~ 1) ifTrue:[
  1583                     ^ self fileFormatError:('unsupported format: nplanes=' , nPlanes printString).
  1583                     ^ self fileFormatError:('unsupported format: nplanes=' , nPlanes printString).
  1647         y := y + tH.
  1647         y := y + tH.
  1648         imageRowOffset := imageRowOffset + (bytesPerRow*tH).
  1648         imageRowOffset := imageRowOffset + (bytesPerRow*tH).
  1649     ].
  1649     ].
  1650 
  1650 
  1651     "Created: / 25-08-2017 / 00:22:31 / cg"
  1651     "Created: / 25-08-2017 / 00:22:31 / cg"
  1652     "Modified: / 27-08-2017 / 15:39:02 / cg"
  1652     "Modified (comment): / 27-08-2017 / 20:42:18 / cg"
  1653 !
  1653 !
  1654 
  1654 
  1655 readUncompressedTiffImageData
  1655 readUncompressedTiffImageData
  1656     |bytesPerRow   "{ Class: SmallInteger }"
  1656     |bytesPerRow   "{ Class: SmallInteger }"
  1657      bitsPerRow    "{ Class: SmallInteger }"
  1657      bitsPerRow    "{ Class: SmallInteger }"
  2816             "/ XML Packets
  2816             "/ XML Packets
  2817             
  2817             
  2818             Verbose == true ifTrue:[ 
  2818             Verbose == true ifTrue:[ 
  2819                 Logger info:'      XMLPACKET: %1' with:value asString
  2819                 Logger info:'      XMLPACKET: %1' with:value asString
  2820             ].
  2820             ].
       
  2821             decodeMetaTags == true ifTrue:[
       
  2822                 metaData at:#xmpData put:value asString.
       
  2823             ].    
  2821             ^ self
  2824             ^ self
  2822         ].
  2825         ].
  2823     ].
  2826     ].
  2824     
  2827     
  2825     (tagType between:18000 and:18999) ifTrue:[
  2828     (tagType between:18000 and:18999) ifTrue:[
  3039         "/ private Photoshop
  3042         "/ private Photoshop
  3040         (tagType == 34377) ifTrue:[
  3043         (tagType == 34377) ifTrue:[
  3041             "/ RICHTIFFIPTC
  3044             "/ RICHTIFFIPTC
  3042             "/ IPTC (International Press Telecommunications Council) metadata.
  3045             "/ IPTC (International Press Telecommunications Council) metadata.
  3043             "/ (see http://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata)
  3046             "/ (see http://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata)
  3044             Verbose == true ifTrue:[ 
       
  3045                 Logger info:'      RICHTIFFIPTC: %1' with:value
       
  3046             ].
       
  3047             decodeMetaTags == true ifTrue:[
  3047             decodeMetaTags == true ifTrue:[
       
  3048                 Verbose == true ifTrue:[ 
       
  3049                     Logger info:'      RICHTIFFIPTC: %1' with:value
       
  3050                 ].
  3048                 self decodePhotoshopImageResourceBlock:value.
  3051                 self decodePhotoshopImageResourceBlock:value.
  3049             ] ifFalse:[
  3052             ] ifFalse:[
  3050                 Verbose == true ifTrue:[ 
  3053                 Verbose == true ifTrue:[ 
  3051                     Logger info:'      skipped decoding of IPTC-PhotoMetadata'
  3054                     Logger info:'      skipped decoding of IPTC-PhotoMetadata'
  3052                 ].
  3055                 ].
  3333 "/ ' val:' print. value print. ' valArr:' print. valueArray printNewline.  
  3336 "/ ' val:' print. value print. ' valArr:' print. valueArray printNewline.  
  3334 "/
  3337 "/
  3335     'TIFFReader [warning]: unknown tag type ' errorPrint. tagType errorPrintCR
  3338     'TIFFReader [warning]: unknown tag type ' errorPrint. tagType errorPrintCR
  3336 
  3339 
  3337     "Modified (format): / 23-05-2017 / 16:12:58 / mawalch"
  3340     "Modified (format): / 23-05-2017 / 16:12:58 / mawalch"
  3338     "Modified: / 27-08-2017 / 19:57:55 / cg"
  3341     "Modified: / 27-08-2017 / 20:46:36 / cg"
  3339 !
  3342 !
  3340 
  3343 
  3341 positionToStrip:stripNr
  3344 positionToStrip:stripNr
  3342     inStream position:(stripOffsets at:stripNr).
  3345     inStream position:(stripOffsets at:stripNr).
  3343 !
  3346 !