TIFFReader.st
changeset 14 20638e830834
parent 11 1d0df18a7049
child 19 8527f194f903
equal deleted inserted replaced
13:f6d396b2bcff 14:20638e830834
    26 TIFFReader comment:'
    26 TIFFReader comment:'
    27 
    27 
    28 COPYRIGHT (c) 1991 by Claus Gittinger
    28 COPYRIGHT (c) 1991 by Claus Gittinger
    29               All Rights Reserved
    29               All Rights Reserved
    30 
    30 
    31 $Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.5 1993-12-11 01:33:46 claus Exp $
    31 $Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.6 1994-01-08 17:10:32 claus Exp $
    32 written Summer 91 by claus
    32 written Summer 91 by claus
    33 '!
    33 '!
    34 
    34 
    35 !TIFFReader class methodsFor:'documentation'!
    35 !TIFFReader class methodsFor:'documentation'!
    36 
    36 
    37 documentation
    37 documentation
    38 "
    38 "
    39     This class knows how to read TIFF files and how to
    39 This class knows how to read TIFF files and how to
    40     write uncompressed TIFF files.
    40 write uncompressed TIFF files.
    41     Only single image files are supported.
    41 
    42     Currently, not all formats are implemented, and of
    42 Only single image files are supported.
    43     those that are not all are tested.
    43 Currently, not all formats are implemented, and of those that are not 
    44     It should work with most rgb, mono and 2-plane greyscale
    44 all are tested.
    45     images, since this is what I have as test material on
    45 It should work with most rgb, mono and 2-plane greyscale
    46     the NeXT.
    46 images, since this is what I have as test material on
    47     It supports reading of uncompressed, LZW and G3 compressed 
    47 the NeXT.
    48     images; JPEG and pacbits are currently not implemented.
    48 It supports reading of uncompressed, LZW and G3 compressed 
    49     Only writing of uncompressed images is currently implemented.
    49 images; JPEG and packbits are currently not implemented.
    50     More formats will come ...
    50 
       
    51 Only writing of uncompressed images is currently implemented.
       
    52 More formats will come ...
    51 "
    53 "
    52 ! !
    54 ! !
    53 
    55 
    54 !TIFFReader class methodsFor:'testing'!
    56 !TIFFReader class methodsFor:'testing'!
    55 
    57 
   271     self writeLong:0.           "start of tags - filled in later"
   273     self writeLong:0.           "start of tags - filled in later"
   272     currentOffset := currentOffset + 4.
   274     currentOffset := currentOffset + 4.
   273 
   275 
   274     "output strips"
   276     "output strips"
   275 
   277 
   276     self writeBits.             "this outputs bits as strips, sets stripOffsets and stripByteCounts"
   278     self writeUncompressedBits. "this outputs bits as strips, sets stripOffsets and stripByteCounts"
   277     self writeStripOffsets.     "this outputs strip offsets, sets stripOffsetsPos"
   279     self writeStripOffsets.     "this outputs strip offsets, sets stripOffsetsPos"
   278     self writeStripByteCounts.  "this outputs strip bytecounts, sets stripByteCountPos"
   280     self writeStripByteCounts.  "this outputs strip bytecounts, sets stripByteCountPos"
   279     self writeBitsPerSample.    "this outputs bitsPerSample, sets bitsPerSamplePos"
   281     self writeBitsPerSample.    "this outputs bitsPerSample, sets bitsPerSamplePos"
   280     photometric == #palette ifTrue:[
   282     photometric == #palette ifTrue:[
   281         self writeColorMap      "this outputs colorMap, sets colorMapPos"
   283         self writeColorMap      "this outputs colorMap, sets colorMapPos"
   290                          (pos printStringRadix:16)) printNewline.
   292                          (pos printStringRadix:16)) printNewline.
   291 "
   293 "
   292     "output tag data"
   294     "output tag data"
   293 
   295 
   294     photometric == #palette ifTrue:[
   296     photometric == #palette ifTrue:[
   295         self writeShort:9.  "9 tags"
   297         self writeShort:10.  "10 tags"
   296     ] ifFalse:[
   298     ] ifFalse:[
   297         self writeShort:8.  "8 tags"
   299         self writeShort:9.   "9 tags"
   298     ].
   300     ].
   299     self writeTag:256.               "image width"
   301     self writeTag:256.               "image width"
   300     self writeTag:257.               "image height"
   302     self writeTag:257.               "image height"
   301     self writeTag:258.               "bits per sample"
   303     self writeTag:258.               "bits per sample"
   302     self writeTag:259.               "compression"
   304     self writeTag:259.               "compression"
   303     self writeTag:262.               "photometric"
   305     self writeTag:262.               "photometric"
   304     self writeTag:273.               "strip offsets"
   306     self writeTag:273.               "strip offsets"
   305     self writeTag:279.               "strip byte counts"
   307     self writeTag:279.               "strip byte counts"
   306     self writeTag:284.               "planarconfig"
   308     self writeTag:284.               "planarconfig"
       
   309     self writeTag:278.               "rowsPerStrip"
   307     photometric == #palette ifTrue:[
   310     photometric == #palette ifTrue:[
   308         self writeTag:320            "colorMap"
   311         self writeTag:320            "colorMap"
   309     ].
   312     ].
   310     self writeLong:0.                "end of tags mark"
   313     self writeLong:0.                "end of tags mark"
       
   314     outStream close
   311 ! !
   315 ! !
   312 
   316 
   313 !TIFFReader methodsFor:'private'!
   317 !TIFFReader methodsFor:'private'!
   314 
   318 
   315 readLongs:n
   319 readLongs:n
   422     ].
   426     ].
   423 
   427 
   424     (tagType == 254) ifTrue:[
   428     (tagType == 254) ifTrue:[
   425         "NewSubfileType"
   429         "NewSubfileType"
   426         "newSubFileType := value."
   430         "newSubFileType := value."
       
   431 "
   427         'newSubfiletype ' print. value printNewline.
   432         'newSubfiletype ' print. value printNewline.
       
   433 "
   428         ^ self
   434         ^ self
   429     ].
   435     ].
   430     (tagType == 255) ifTrue:[
   436     (tagType == 255) ifTrue:[
   431         "SubfileType"
   437         "SubfileType"
   432         subFileType := value.
   438         subFileType := value.
       
   439 "
   433         'subfiletype ' print. value printNewline.
   440         'subfiletype ' print. value printNewline.
       
   441 "
   434         ^ self
   442         ^ self
   435     ].
   443     ].
   436     (tagType == 256) ifTrue:[
   444     (tagType == 256) ifTrue:[
   437         "ImageWidth"
   445         "ImageWidth"
   438         width := value.
   446         width := value.
   439         'width ' print. width printNewline.
   447         'width ' print. width printNewline.
   440         ^ self
   448 "
       
   449         ^ self
       
   450 "
   441     ].
   451     ].
   442     (tagType == 257) ifTrue:[
   452     (tagType == 257) ifTrue:[
   443         "ImageHeight"
   453         "ImageHeight"
   444         height := value.
   454         height := value.
       
   455 "
   445         'height ' print. height  printNewline.
   456         'height ' print. height  printNewline.
       
   457 "
   446         ^ self
   458         ^ self
   447     ].
   459     ].
   448     (tagType == 258) ifTrue:[
   460     (tagType == 258) ifTrue:[
   449         "bitspersample"
   461         "bitspersample"
   450          bitsPerSample := valueArray.
   462          bitsPerSample := valueArray.
       
   463 "
   451         'bitspersample ' print. bitsPerSample printNewline.
   464         'bitspersample ' print. bitsPerSample printNewline.
       
   465 "
   452         ^ self
   466         ^ self
   453     ].
   467     ].
   454     (tagType == 259) ifTrue:[
   468     (tagType == 259) ifTrue:[
   455         "compression"
   469         "compression"
   456         compression := value.
   470         compression := value.
       
   471 "
   457         'compression ' print. compression printNewline.
   472         'compression ' print. compression printNewline.
       
   473 "
   458         ^ self
   474         ^ self
   459     ].
   475     ].
   460     (tagType == 262) ifTrue:[
   476     (tagType == 262) ifTrue:[
   461         "photometric"
   477         "photometric"
   462         (value == 0) ifTrue:[
   478         (value == 0) ifTrue:[
   478                 ]
   494                 ]
   479               ]
   495               ]
   480             ]
   496             ]
   481           ]
   497           ]
   482         ].
   498         ].
       
   499 "
   483         'photometric ' print. photometric printNewline.
   500         'photometric ' print. photometric printNewline.
       
   501 "
   484         ^ self
   502         ^ self
   485     ].
   503     ].
   486     (tagType == 263) ifTrue:[
   504     (tagType == 263) ifTrue:[
   487         "Treshholding"
   505         "Treshholding"
   488         "threshholding := value."
   506         "threshholding := value."
       
   507 "
   489         'treshholding ' print. value printNewline.
   508         'treshholding ' print. value printNewline.
       
   509 "
   490         ^ self
   510         ^ self
   491     ].
   511     ].
   492     (tagType == 264) ifTrue:[
   512     (tagType == 264) ifTrue:[
   493         "CellWidth"
   513         "CellWidth"
   494         "cellWidth:= value."
   514         "cellWidth:= value."
       
   515 "
   495         'cellWidth ' print. value printNewline.
   516         'cellWidth ' print. value printNewline.
       
   517 "
   496         ^ self
   518         ^ self
   497     ].
   519     ].
   498     (tagType == 265) ifTrue:[
   520     (tagType == 265) ifTrue:[
   499         "CellLength"
   521         "CellLength"
   500         "cellLength:= value."
   522         "cellLength:= value."
       
   523 "
   501         'cellLength ' print. value printNewline.
   524         'cellLength ' print. value printNewline.
       
   525 "
   502         ^ self
   526         ^ self
   503     ].
   527     ].
   504     (tagType == 266) ifTrue:[
   528     (tagType == 266) ifTrue:[
   505         "fillOrder"
   529         "fillOrder"
   506         (value == 1) ifTrue:[
   530         (value == 1) ifTrue:[
   510             fillOrder := #lsb
   534             fillOrder := #lsb
   511           ] ifFalse:[
   535           ] ifFalse:[
   512             fillOrder := nil
   536             fillOrder := nil
   513           ]
   537           ]
   514         ].
   538         ].
       
   539 "
   515         'fillorder ' print. fillOrder printNewline.
   540         'fillorder ' print. fillOrder printNewline.
       
   541 "
   516         ^ self
   542         ^ self
   517     ].
   543     ].
   518     (tagType == 269) ifTrue:[
   544     (tagType == 269) ifTrue:[
   519         "documentName"
   545         "documentName"
       
   546 "
   520         'documentName ' print. value printNewline.
   547         'documentName ' print. value printNewline.
       
   548 "
   521         ^ self
   549         ^ self
   522     ].
   550     ].
   523     (tagType == 270) ifTrue:[
   551     (tagType == 270) ifTrue:[
   524         "imageDescription"
   552         "imageDescription"
       
   553 "
   525         'imageDescription ' print. value printNewline.
   554         'imageDescription ' print. value printNewline.
       
   555 "
   526         ^ self
   556         ^ self
   527     ].
   557     ].
   528     (tagType == 271) ifTrue:[
   558     (tagType == 271) ifTrue:[
   529         "make"
   559         "make"
       
   560 "
   530         'make ' print. value printNewline.
   561         'make ' print. value printNewline.
       
   562 "
   531         ^ self
   563         ^ self
   532     ].
   564     ].
   533     (tagType == 272) ifTrue:[
   565     (tagType == 272) ifTrue:[
   534         "model"
   566         "model"
       
   567 "
   535         'model ' print. value printNewline.
   568         'model ' print. value printNewline.
       
   569 "
   536         ^ self
   570         ^ self
   537     ].
   571     ].
   538     (tagType == 273) ifTrue:[
   572     (tagType == 273) ifTrue:[
   539         "stripoffsets"
   573         "stripoffsets"
   540         stripOffsets := valueArray.
   574         stripOffsets := valueArray.
       
   575 "
   541         'stripOffsets Array(' print. stripOffsets size print. ')' printNewline.
   576         'stripOffsets Array(' print. stripOffsets size print. ')' printNewline.
       
   577 "
   542         ^ self
   578         ^ self
   543     ].
   579     ].
   544     (tagType == 274) ifTrue:[
   580     (tagType == 274) ifTrue:[
   545         "Orientation"
   581         "Orientation"
   546         "orientation:= value."
   582         "orientation:= value."
       
   583 "
   547         'orientation ' print. value printNewline.
   584         'orientation ' print. value printNewline.
       
   585 "
   548         ^ self
   586         ^ self
   549     ].
   587     ].
   550     (tagType == 277) ifTrue:[
   588     (tagType == 277) ifTrue:[
   551         "samplesPerPixel"
   589         "samplesPerPixel"
   552         samplesPerPixel := value.
   590         samplesPerPixel := value.
       
   591 "
   553         'samplesperpixel ' print. samplesPerPixel printNewline.
   592         'samplesperpixel ' print. samplesPerPixel printNewline.
       
   593 "
   554         ^ self
   594         ^ self
   555     ].
   595     ].
   556     (tagType == 278) ifTrue:[
   596     (tagType == 278) ifTrue:[
   557         "rowsperstrip"
   597         "rowsperstrip"
   558         rowsPerStrip := value.
   598         rowsPerStrip := value.
       
   599 "
   559         'rowsperstrip ' print. rowsPerStrip printNewline.
   600         'rowsperstrip ' print. rowsPerStrip printNewline.
       
   601 "
   560         ^ self
   602         ^ self
   561     ].
   603     ].
   562     (tagType == 279) ifTrue:[
   604     (tagType == 279) ifTrue:[
   563         "stripbytecount"
   605         "stripbytecount"
   564         stripByteCounts := valueArray.
   606         stripByteCounts := valueArray.
       
   607 "
   565         'stripByteCounts Array(' print. 
   608         'stripByteCounts Array(' print. 
   566         stripByteCounts size print.
   609         stripByteCounts size print.
   567         ')' printNewline.
   610         ')' printNewline.
       
   611 "
   568         ^ self
   612         ^ self
   569     ].
   613     ].
   570     (tagType == 280) ifTrue:[
   614     (tagType == 280) ifTrue:[
   571         "MinSampleValue"
   615         "MinSampleValue"
   572         "minSampleValue:= value."
   616         "minSampleValue:= value."
       
   617 "
   573         'minSampleValue ' print. value printNewline.
   618         'minSampleValue ' print. value printNewline.
       
   619 "
   574         ^ self
   620         ^ self
   575     ].
   621     ].
   576     (tagType == 281) ifTrue:[
   622     (tagType == 281) ifTrue:[
   577         "MaxSampleValue"
   623         "MaxSampleValue"
   578         "maxSampleValue:= value."
   624         "maxSampleValue:= value."
       
   625 "
   579         'maxSampleValue ' print. value printNewline.
   626         'maxSampleValue ' print. value printNewline.
       
   627 "
   580         ^ self
   628         ^ self
   581     ].
   629     ].
   582     (tagType == 282) ifTrue:[
   630     (tagType == 282) ifTrue:[
   583         "xResolution"
   631         "xResolution"
       
   632 "
   584         'xres ' print. value printNewline.
   633         'xres ' print. value printNewline.
       
   634 "
   585         ^ self
   635         ^ self
   586     ].
   636     ].
   587     (tagType == 283) ifTrue:[
   637     (tagType == 283) ifTrue:[
   588         "yResolution"
   638         "yResolution"
       
   639 "
   589         'yres ' print. value printNewline.
   640         'yres ' print. value printNewline.
       
   641 "
   590         ^ self
   642         ^ self
   591     ].
   643     ].
   592     (tagType == 284) ifTrue:[
   644     (tagType == 284) ifTrue:[
   593         "planarconfig"
   645         "planarconfig"
   594         (value == 1) ifTrue:[
   646         (value == 1) ifTrue:[
   598             planarConfiguration := 2
   650             planarConfiguration := 2
   599           ] ifFalse:[
   651           ] ifFalse:[
   600             planarConfiguration := nil
   652             planarConfiguration := nil
   601           ]
   653           ]
   602         ].
   654         ].
       
   655 "
   603         'planarconfig ' print. planarConfiguration printNewline.
   656         'planarconfig ' print. planarConfiguration printNewline.
       
   657 "
   604         ^ self
   658         ^ self
   605     ].
   659     ].
   606     (tagType == 285) ifTrue:[
   660     (tagType == 285) ifTrue:[
   607         "pageName"
   661         "pageName"
       
   662 "
   608         'pageName ' print. value printNewline.
   663         'pageName ' print. value printNewline.
       
   664 "
   609         ^ self
   665         ^ self
   610     ].
   666     ].
   611     (tagType == 286) ifTrue:[
   667     (tagType == 286) ifTrue:[
   612         "xPosition"
   668         "xPosition"
       
   669 "
   613         'xPos ' print. value printNewline.
   670         'xPos ' print. value printNewline.
       
   671 "
   614         ^ self
   672         ^ self
   615     ].
   673     ].
   616     (tagType == 287) ifTrue:[
   674     (tagType == 287) ifTrue:[
   617         "yPosition"
   675         "yPosition"
       
   676 "
   618         'yPos ' print. value printNewline.
   677         'yPos ' print. value printNewline.
       
   678 "
   619         ^ self
   679         ^ self
   620     ].
   680     ].
   621     (tagType == 288) ifTrue:[
   681     (tagType == 288) ifTrue:[
   622         "freeOffsets"
   682         "freeOffsets"
       
   683 "
   623         'freeOffsets ' print. value printNewline.
   684         'freeOffsets ' print. value printNewline.
       
   685 "
   624         ^ self
   686         ^ self
   625     ].
   687     ].
   626     (tagType == 289) ifTrue:[
   688     (tagType == 289) ifTrue:[
   627         "freeByteCounts"
   689         "freeByteCounts"
       
   690 "
   628         'freeByteCounts ' print. value printNewline.
   691         'freeByteCounts ' print. value printNewline.
       
   692 "
   629         ^ self
   693         ^ self
   630     ].
   694     ].
   631     (tagType == 290) ifTrue:[
   695     (tagType == 290) ifTrue:[
   632         "grayResponceUnit"
   696         "grayResponceUnit"
       
   697 "
   633         'grayResponceUnit' print. value printNewline.
   698         'grayResponceUnit' print. value printNewline.
       
   699 "
   634         ^ self
   700         ^ self
   635     ].
   701     ].
   636     (tagType == 291) ifTrue:[
   702     (tagType == 291) ifTrue:[
   637         "grayResponceCurve"
   703         "grayResponceCurve"
       
   704 "
   638         'grayResponceCurve' print. value printNewline.
   705         'grayResponceCurve' print. value printNewline.
       
   706 "
   639         ^ self
   707         ^ self
   640     ].
   708     ].
   641     (tagType == 292) ifTrue:[
   709     (tagType == 292) ifTrue:[
   642         "group3options"
   710         "group3options"
   643         group3options := value.
   711         group3options := value.
       
   712 "
   644         'group3options ' print. group3options printNewline.
   713         'group3options ' print. group3options printNewline.
       
   714 "
   645         ^ self
   715         ^ self
   646     ].
   716     ].
   647     (tagType == 293) ifTrue:[
   717     (tagType == 293) ifTrue:[
   648         "group4options"
   718         "group4options"
   649         "group4options := value."
   719         "group4options := value."
       
   720 "
   650         'group4options ' print. value printNewline.
   721         'group4options ' print. value printNewline.
       
   722 "
   651         ^ self
   723         ^ self
   652     ].
   724     ].
   653     (tagType == 296) ifTrue:[
   725     (tagType == 296) ifTrue:[
   654         "resolutionunit"
   726         "resolutionunit"
       
   727 "
   655         (value == 1) ifTrue:[
   728         (value == 1) ifTrue:[
   656             'res-unit pixel' printNewline
   729             'res-unit pixel' printNewline
   657         ] ifFalse:[
   730         ] ifFalse:[
   658             (value == 2) ifTrue:[
   731             (value == 2) ifTrue:[
   659                 'res-unit inch' printNewline
   732                 'res-unit inch' printNewline
   663                 ] ifFalse:[
   736                 ] ifFalse:[
   664                     'res-unit invalid' printNewline
   737                     'res-unit invalid' printNewline
   665                 ]
   738                 ]
   666             ]
   739             ]
   667         ].
   740         ].
       
   741 "
   668         "resolutionUnit := value."
   742         "resolutionUnit := value."
   669         ^ self
   743         ^ self
   670     ].
   744     ].
   671     (tagType == 297) ifTrue:[
   745     (tagType == 297) ifTrue:[
   672         "pageNumber"
   746         "pageNumber"
   673         "pageNumber := value."
   747         "pageNumber := value."
       
   748 "
   674         'pageNumber ' print. value printNewline.
   749         'pageNumber ' print. value printNewline.
       
   750 "
   675         ^ self
   751         ^ self
   676     ].
   752     ].
   677     (tagType == 300) ifTrue:[
   753     (tagType == 300) ifTrue:[
   678         "colorResponceUnit"
   754         "colorResponceUnit"
       
   755 "
   679         'colorResponceUnit' print. value printNewline.
   756         'colorResponceUnit' print. value printNewline.
       
   757 "
   680         ^ self
   758         ^ self
   681     ].
   759     ].
   682     (tagType == 301) ifTrue:[
   760     (tagType == 301) ifTrue:[
   683         "colorResponceCurve"
   761         "colorResponceCurve"
       
   762 "
   684         'colorResponceCurve' print. value printNewline.
   763         'colorResponceCurve' print. value printNewline.
       
   764 "
   685         ^ self
   765         ^ self
   686     ].
   766     ].
   687     (tagType == 306) ifTrue:[
   767     (tagType == 306) ifTrue:[
   688         "dateTime"
   768         "dateTime"
       
   769 "
   689         'dateTime ' print. value printNewline.
   770         'dateTime ' print. value printNewline.
       
   771 "
   690         ^ self
   772         ^ self
   691     ].
   773     ].
   692     (tagType == 315) ifTrue:[
   774     (tagType == 315) ifTrue:[
   693         "artist"
   775         "artist"
       
   776 "
   694         'artist ' print. value printNewline.
   777         'artist ' print. value printNewline.
       
   778 "
   695         ^ self
   779         ^ self
   696     ].
   780     ].
   697     (tagType == 317) ifTrue:[
   781     (tagType == 317) ifTrue:[
   698         "predictor"
   782         "predictor"
   699         predictor := value.
   783         predictor := value.
       
   784 "
   700         'predictor ' print. predictor printNewline.
   785         'predictor ' print. predictor printNewline.
       
   786 "
   701         ^ self
   787         ^ self
   702     ].
   788     ].
   703     (tagType == 320) ifTrue:[
   789     (tagType == 320) ifTrue:[
   704         "colorMap"
   790         "colorMap"
       
   791 "
   705         'colorMap (size=' print. valueArray size print. ')' printNewline.
   792         'colorMap (size=' print. valueArray size print. ')' printNewline.
       
   793 "
   706         n := valueArray size // 3.
   794         n := valueArray size // 3.
   707         colorMap := Array new:3.
   795         colorMap := Array new:3.
   708         colorMap at:1 put:(valueArray copyFrom:1 to:n).
   796         colorMap at:1 put:(valueArray copyFrom:1 to:n).
   709         colorMap at:2 put:(valueArray copyFrom:n+1 to:2*n).
   797         colorMap at:2 put:(valueArray copyFrom:n+1 to:2*n).
   710         colorMap at:3 put:(valueArray copyFrom:2*n+1 to:3*n).
   798         colorMap at:3 put:(valueArray copyFrom:2*n+1 to:3*n).
   723 ' val:' print. value print. ' valArr:' print. valueArray printNewline.  
   811 ' val:' print. value print. ' valArr:' print. valueArray printNewline.  
   724 
   812 
   725     'unknown type ' print. tagType printNewline
   813     'unknown type ' print. tagType printNewline
   726 !
   814 !
   727 
   815 
   728 writeBits
   816 writeUncompressedBits
   729     "write bits as one strip"
   817     "write bits as one or multiple strips"
   730 
   818 
   731     |offs bytesPerRow|
   819     |offs bytesPerRow nBytes|
   732 
   820 
   733     data size < 16rFFFF ifTrue:[
   821     nBytes := data size.
       
   822     nBytes < 16rFFFF ifTrue:[
   734         stripOffsets := Array with:(outStream position - 1).
   823         stripOffsets := Array with:(outStream position - 1).
   735         stripByteCounts := Array with:(data size).
   824         stripByteCounts := Array with:nBytes.
   736         outStream nextPutBytes:data size from:data.
   825         outStream nextPutBytes:nBytes from:data.
   737         rowsPerStrip := height
   826         rowsPerStrip := height
   738     ] ifFalse:[
   827     ] ifFalse:[
   739         stripOffsets := Array new:height.
   828         stripOffsets := Array new:height.
   740         bytesPerRow := data size // height.
   829         bytesPerRow := nBytes // height.
   741         stripByteCounts := (Array new:height) atAllPut:bytesPerRow.
   830         stripByteCounts := Array new:height withAll:bytesPerRow.
   742 
   831 
   743         offs := 1.
   832         offs := 1.
   744         1 to:height do:[:row |
   833         1 to:height do:[:row |
   745             stripOffsets at:row put:(outStream position - 1).
   834             stripOffsets at:row put:(outStream position - 1).
   746             outStream nextPutBytes:bytesPerRow from:data startingAt:offs.
   835             outStream nextPutBytes:bytesPerRow from:data startingAt:offs.
   747             offs := offs + bytesPerRow
   836             offs := offs + bytesPerRow
   748         ].
   837         ].
   749         rowsPerStrip := 1
   838         rowsPerStrip := 1
   750     ].
   839     ].
       
   840 "
   751     'stripOffsets: ' print. stripOffsets printNewline.
   841     'stripOffsets: ' print. stripOffsets printNewline.
   752     'stripByteCounts: ' print. stripByteCounts printNewline.
   842     'stripByteCounts: ' print. stripByteCounts printNewline.
       
   843 "
   753 !
   844 !
   754 
   845 
   755 writeColorMap
   846 writeColorMap
   756     colorMapPos := outStream position.
   847     colorMapPos := outStream position.
   757     colorMap do:[:subMap |
   848     colorMap do:[:subMap |
   997     (value isNil and:[address isNil]) ifTrue:[
  1088     (value isNil and:[address isNil]) ifTrue:[
   998         self error:'unhandled tag'.
  1089         self error:'unhandled tag'.
   999         ^ self
  1090         ^ self
  1000     ].
  1091     ].
  1001 
  1092 
       
  1093 "
  1002 'tag:' print. tagType print. ' typ:' print. numberType print.
  1094 'tag:' print. tagType print. ' typ:' print. numberType print.
  1003 ' len:' print. count print.
  1095 ' len:' print. count print.
  1004 ' val:' print. value printNewline.  
  1096 ' val:' print. value printNewline.  
       
  1097 "
  1005 
  1098 
  1006     self writeShort:tagType.
  1099     self writeShort:tagType.
  1007     numberType == #short ifTrue:[
  1100     numberType == #short ifTrue:[
  1008         self writeShort:3.
  1101         self writeShort:3.
  1009         self writeLong:count.
  1102         self writeLong:count.
  1133     [row <= height] whileTrue:[
  1226     [row <= height] whileTrue:[
  1134         stripNr := stripNr + 1.
  1227         stripNr := stripNr + 1.
  1135         nBytes := stripByteCounts at:stripNr.
  1228         nBytes := stripByteCounts at:stripNr.
  1136         inStream position:((stripOffsets at:stripNr) + 1).
  1229         inStream position:((stripOffsets at:stripNr) + 1).
  1137 
  1230 
  1138             inStream nextBytes:nBytes 
  1231         inStream nextBytes:nBytes into:data startingAt:offset.
  1139                           into:data
       
  1140                     startingAt:offset.
       
  1141         offset := offset + nBytes.
  1232         offset := offset + nBytes.
  1142         row := row + rowsPerStrip
  1233         row := row + rowsPerStrip
  1143     ]
  1234     ]
  1144 !
  1235 !
  1145 
  1236