GIFReader.st
changeset 21 66b31c91177f
parent 20 7fd1b1ec5f6d
child 23 11c422f6d825
equal deleted inserted replaced
20:7fd1b1ec5f6d 21:66b31c91177f
    16          poolDictionaries:''
    16          poolDictionaries:''
    17          category:'Graphics-Support'
    17          category:'Graphics-Support'
    18 !
    18 !
    19 
    19 
    20 GIFReader comment:'
    20 GIFReader comment:'
    21 
       
    22 COPYRIGHT (c) 1991 by Claus Gittinger
    21 COPYRIGHT (c) 1991 by Claus Gittinger
    23               All Rights Reserved
    22               All Rights Reserved
    24 
       
    25 $Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.6 1994-02-25 13:11:30 claus Exp $
       
    26 
       
    27 written Dec 91 by claus
       
    28 '!
    23 '!
    29 
    24 
    30 !GIFReader class methodsFor:'documentation'!
    25 !GIFReader class methodsFor:'documentation'!
    31 
    26 
       
    27 copyright
       
    28 "
       
    29  COPYRIGHT (c) 1991 by Claus Gittinger
       
    30               All Rights Reserved
       
    31 
       
    32  This software is furnished under a license and may be used
       
    33  only in accordance with the terms of that license and with the
       
    34  inclusion of the above copyright notice.   This software may not
       
    35  be provided or otherwise made available to, or used by, any
       
    36  other person.  No title to or ownership of the software is
       
    37  hereby transferred.
       
    38 "
       
    39 !
       
    40 
       
    41 version
       
    42 "
       
    43 $Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.7 1994-06-03 00:52:39 claus Exp $
       
    44 "
       
    45 !
       
    46 
    32 documentation
    47 documentation
    33 "
    48 "
    34     this class provides methods for loading and saving GIF pictures.
    49     this class provides methods for loading and saving GIF pictures.
    35     It has been tested with some different GIF89a pictures, I dont
    50     It has been tested with some different GIF87a pictures, I dont
    36     know, if it works with other GIF versions.
    51     know, if it works with other GIF versions.
    37     GIF extension blocks are not handled.
    52     GIF extension blocks are not handled.
    38 
    53 
    39     GIF file writing is not implemented (use TIFF).
    54     GIF file writing is not implemented (use TIFF).
    40 
    55 
    41     legal stuff extracted from GIF89a documentation:
    56     legal stuff extracted from GIF87a documentation:
    42 
    57 
    43     CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free
    58     CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free
    44     license for the use of the Graphics Interchange Format(sm) in computer
    59     license for the use of the Graphics Interchange Format(sm) in computer
    45     software; computer software utilizing GIF(sm) must acknowledge ownership of the
    60     software; computer software utilizing GIF(sm) must acknowledge ownership of the
    46     Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in
    61     Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in
    67     inStream close.
    82     inStream close.
    68 
    83 
    69     (id = 'GIF87a') ifFalse:[
    84     (id = 'GIF87a') ifFalse:[
    70         (id startsWith:'GIF') ifFalse:[^ false].
    85         (id startsWith:'GIF') ifFalse:[^ false].
    71 
    86 
    72         'not GIF87a - untested' printNewline.
    87         'GIFRDR: not GIF87a - untested' errorPrintNewline.
    73     ].
    88     ].
    74     ^ true
    89     ^ true
    75 ! !
    90 ! !
    76 
    91 
    77 !GIFReader methodsFor:'reading from file'!
    92 !GIFReader methodsFor:'reading from file'!
   100     "all I had for testing where GIF87a files;
   115     "all I had for testing where GIF87a files;
   101      I hope later versions work too ..."
   116      I hope later versions work too ..."
   102 
   117 
   103     (id ~= 'GIF87a') ifTrue:[
   118     (id ~= 'GIF87a') ifTrue:[
   104         (id startsWith:'GIF') ifFalse:[
   119         (id startsWith:'GIF') ifFalse:[
   105             'not a gif file' printNewline.
   120             'GIFRDR: not a gif file' errorPrintNewline.
   106             inStream close.
   121             inStream close.
   107             ^ nil
   122             ^ nil
   108         ].
   123         ].
   109         'not a gif87a file - hope that works' printNewline.
   124         'GIFRDR: not a GIF87a file - hope that works' errorPrintNewline.
   110     ].
   125     ].
   111 
   126 
   112     "get screen dimensions (not used)"
   127     "get screen dimensions (not used)"
   113 
   128 
   114     scrWidth := inStream nextShortMSB:false.
   129     scrWidth := inStream nextShortMSB:false.
   134     ].
   149     ].
   135 
   150 
   136     "image separator"
   151     "image separator"
   137     byte := inStream nextByte.
   152     byte := inStream nextByte.
   138     (byte ~~ 16r2C) ifTrue:[
   153     (byte ~~ 16r2C) ifTrue:[
   139         'corrupted gif file (no imgSep)' printNewline.
   154         'GIFRDR: corrupted gif file (no imgSep)' errorPrintNewline.
   140         ^ nil
   155         ^ nil
   141     ].
   156     ].
   142 
   157 
   143     "get image data"
   158     "get image data"
   144     leftOffs := inStream nextShortMSB:false.
   159     leftOffs := inStream nextShortMSB:false.
   275      redVal|
   290      redVal|
   276 
   291 
   277     sz := redMap size.
   292     sz := redMap size.
   278 
   293 
   279     1 to:sz do:[:i |
   294     1 to:sz do:[:i |
   280 	redVal := redMap at:i.
   295         redVal := redMap at:i.
   281         redVal ~~ (greenMap at:i) ifTrue:[^ false].
   296         redVal ~~ (greenMap at:i) ifTrue:[^ false].
   282         redVal ~~ (blueMap at:i) ifTrue:[^ false].
   297         redVal ~~ (blueMap at:i) ifTrue:[^ false].
   283     ].
   298     ].
   284     ^ true
   299     ^ true
   285 !
   300 !