Pavel 

why not moving this class on the ImageWriter package
because 
        - I do not like this Smalltalk globals at: ifPresent: 
        especially when there is no default.

        - This method does not make sense without the ImageReadWriter


Form classSide>>fromBinaryStream: (in category 'instance creation') 
-----fromBinaryStream: aBinaryStream
        "Read a Form or ColorForm from given file, using the first byte of the 
file to guess its format. Currently handles: GIF, uncompressed BMP, and both 
old and new DisplayObject writeOn: formats, JPEG, and PCX. Return nil if the 
file could not be read or was of an unrecognized format."
  
        | firstByte |
        aBinaryStream binary.
        firstByte := aBinaryStream next.
        firstByte = 1 ifTrue: [
                "old Squeakform format"
                ^ self new readFromOldFormat: aBinaryStream].
        firstByte = 2 ifTrue: [
                "new Squeak form format"
                ^ self new readFrom: aBinaryStream].
  
        "Try for JPG, GIF, or PCX..."
        "Note: The following call closes the stream."
+       Smalltalk globals at: #ImageReadWriter ifPresent: [:imageReadWriter |
+               ^ imageReadWriter formFromStream: aBinaryStream]

Reply via email to