WindowsIconReader.st
author Claus Gittinger <cg@exept.de>
Mon, 01 Sep 2003 16:47:57 +0200
changeset 1805 93f557cbe600
parent 1790 41f36b5a29c3
child 1846 d29322944b05
permissions -rw-r--r--
category changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     1
"
3f9277473954 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
     3
	      All Rights Reserved
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     4
3f9277473954 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
3f9277473954 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
3f9277473954 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3f9277473954 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3f9277473954 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
3f9277473954 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
3f9277473954 Initial revision
claus
parents:
diff changeset
    11
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    12
1385
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    13
"{ Package: 'stx:libview2' }"
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    14
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    15
ImageReader subclass:#WindowsIconReader
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
    16
	instanceVariableNames:''
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
    17
	classVariableNames:''
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
    18
	poolDictionaries:''
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
    19
	category:'Graphics-Images-Readers'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    20
!
3f9277473954 Initial revision
claus
parents:
diff changeset
    21
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    22
!WindowsIconReader class methodsFor:'documentation'!
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    23
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    24
copyright
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    25
"
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    26
 COPYRIGHT (c) 1993 by Claus Gittinger
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
    27
	      All Rights Reserved
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    28
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    29
 This software is furnished under a license and may be used
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    30
 only in accordance with the terms of that license and with the
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    32
 be provided or otherwise made available to, or used by, any
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    33
 other person.  No title to or ownership of the software is
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    34
 hereby transferred.
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    35
"
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    36
!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    37
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    38
documentation
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    39
"
32
6bdcb6da4d4f *** empty log message ***
claus
parents: 28
diff changeset
    40
    this class provides methods for loading Windows and OS2 icon files.
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
    41
    Image writing is only supported for BMP format with depth 1,4,8 and 24 bit images.
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    42
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    43
    The reader tries to figure out which version of BMP/ICO is used.
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    44
    It seems to be able to load most formats, but who knows ...
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    45
1385
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    46
    The class name *IconReader is a bad, historic choice - it ws originally
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    47
    written to read icons only, but evolved over time and it should now be also
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    48
    capapble of reading bmp and cursor files.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    49
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    50
    [See also:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
    51
        Image Form Icon
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    52
        BlitImageReader FaceReader GIFReader JPEGReader PBMReader PCXReader 
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    53
        ST80FormReader SunRasterReader TargaReader TIFFReader  
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    54
        XBMReader XPMReader XWDReader 
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
    55
"
1385
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    56
!
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    57
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    58
fileFormatDescription
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    59
"
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    60
    Information from http://www.daubnet.com/formats/BMP.html - no Warranty.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    61
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    62
          Name           Size                Description
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    63
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    64
      Header            14 bytes            Windows Structure: BITMAPFILEHEADER
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    65
          Signature      2 bytes             'BM'
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    66
          FileSize       4 bytes             File size in bytes
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    67
          reserved       4 bytes             unused (=0)
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    68
          DataOffset     4 bytes             File offset to Raster Data
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    69
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    70
      InfoHeader        40 bytes            Windows Structure: BITMAPINFOHEADER
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    71
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    72
          Size           4 bytes             Size of InfoHeader =40 
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    73
          Width          4 bytes             Bitmap Width
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    74
          Height         4 bytes             Bitmap Height
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    75
          Planes         2 bytes             Number of Planes (=1)
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    76
          BitCount       2 bytes             Bits per Pixel   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    77
                                             1 = monochrome palette. NumColors = 1   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    78
                                             4 = 4bit palletized. NumColors = 16   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    79
                                             8 = 8bit palletized. NumColors = 256  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    80
                                             16 = 16bit RGB. NumColors = 65536 (?)  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    81
                                             24 = 24bit RGB. NumColors = 16M
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    82
          Compression    4 bytes             Type of Compression   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    83
                                             0 = BI_RGB   no compression   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    84
                                             1 = BI_RLE8 8bit RLE encoding   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    85
                                             2 = BI_RLE4 4bit RLE encoding
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    86
          ImageSize      4 bytes             (compressed) Size of Image  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    87
                                             It is valid to set this =0 if Compression = 0
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    88
          XpixelsPerM    4 bytes             horizontal resolution: Pixels/meter
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    89
          YpixelsPerM    4 bytes             vertical resolution: Pixels/meter
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    90
          ColorsUsed     4 bytes             Number of actually used colors
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    91
          ColorsImportant
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    92
                         4 bytes             Number of important colors  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    93
                                             0 = all
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    94
       ColorTable        4 * NumColors bytes
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    95
                                             present only if Info.BitsPerPixel <= 8   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    96
                                             colors should be ordered by importance
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    97
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    98
            Red           1 byte              Red intensity
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
    99
            Green         1 byte              Green intensity
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   100
            Blue          1 byte              Blue intensity
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   101
            reserved      1 byte             unused (=0)
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   102
          repeated NumColors times
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   103
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   104
       Raster Data      Info.ImageSize bytes     The pixel data
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   105
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   106
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   107
Raster Data encoding:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   108
       Depending on the image's BitCount and on the Compression flag there are 6 different encoding schemes. 
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   109
       All of them share the following:  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   110
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   111
       Pixels are stored bottom-up, left-to-right. Pixel lines are padded with zeros to end on a 32bit (4byte) boundary. For
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   112
       uncompressed formats every line will have the same number of bytes. Color indices are zero based, meaning a pixel
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   113
       color of 0 represents the first color table entry, a pixel color of 255 (if there are that many) represents the 256th entry.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   114
       For images with more than 256 colors there is no color table. 
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   115
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   116
Raster Data encoding for 1bit / black & white images:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   117
       BitCount = 1 Compression = 0  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   118
       Every byte holds 8 pixels, its highest order bit representing the leftmost pixel of those. There are 2 color table entries.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   119
       Some readers will ignore them though, and assume that 0 is black and 1 is white. If you are storing black and white
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   120
       pictures you should stick to this, with any other 2 colors this is not an issue. Remember padding with zeros up to a
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   121
       32bit boundary (This can be up to 31 zeros/pixels!!)                                                                 
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   122
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   123
Raster Data encoding for 4bit / 16 color images:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   124
       BitCount = 4 Compression = 0  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   125
       Every byte holds 2 pixels, its high order 4 bits representing the left of those. There are 16 color table entries. These
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   126
       colors do not have to be the 16 MS-Windows standard colors. Padding each line with zeros up to a 32bit boundary
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   127
       will result in up to 28 zeros = 7 'wasted pixels'.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   128
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   129
Raster Data encoding for 8bit / 256 color images:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   130
       BitCount = 8 Compression = 0  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   131
       Every byte holds 1 pixel. There are 256 color table entries. Padding each line with zeros up to a 32bit boundary will
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   132
       result in up to 3 bytes of zeros = 3 'wasted pixels'.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   133
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   134
Raster Data encoding for 16bit / hicolor images:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   135
       BitCount = 16 Compression = 0  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   136
       Every 2bytes / 16bit holds 1 pixel.   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   137
       <information missing: the 16 bit was introduced together with Video For Windows? Is it a memory-only-format?>  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   138
       The pixels are no color table pointers. There are no color table entries. Padding each line with zeros up to a 16bit
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   139
       boundary will result in up to 2 zero bytes.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   140
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   141
Raster Data encoding for 24bit / truecolor images:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   142
       BitCount = 24 Compression = 0  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   143
       Every 4bytes / 32bit holds 1 pixel. The first holds its red, the second its green, and the third its blue intensity. The
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   144
       fourth byte is reserved and should be zero. There are no color table entries. The pixels are no color table pointers. No
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   145
       zero padding necessary.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   146
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   147
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   148
Raster Data compression for 4bit / 16 color images:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   149
       BitCount = 4 Compression = 2  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   150
       The pixel data is stored in 2bytes / 16bit chunks.  The first of these specifies the number of consecutive pixels with the
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   151
       same pair of color. The second byte defines two color indices. The resulting pixel pattern will be interleaved
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   152
       high-order 4bits and low order 4 bits (ABABA...). If the first byte is zero, the second defines an escape code. The
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   153
       End-of-Bitmap is zero padded to end on a 32bit boundary. Due to the 16bit-ness of this structure this will always be
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   154
       either two zero bytes or none.   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   155
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   156
        n (byte 1) c (Byte 2)                                       Description
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   157
        >0        any      n pixels are to be drawn. The 1st, 3rd, 5th, ... pixels' color is in c's high-order 4 bits, the even
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   158
                            pixels' color is in c's low-order 4 bits. If both color indices are the same, it results in just n
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   159
                            pixels of color c
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   160
        0         0        End-of-line
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   161
        0         1        End-of-Bitmap
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   162
        0         2        Delta. The following 2 bytes define an unsigned offset in x and y direction (y being up) The
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   163
                            skipped pixels should get a color zero.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   164
        0         >=3      The following c bytes will be read as single pixel colors just as in uncompressed files. up to 12
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   165
                            bits of zeros follow, to put the file/memory pointer on a 16bit boundary again.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   166
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   167
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   168
                                      Example for 4bit RLE
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   169
        Compressed Data                           Expanded data
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   170
        03 04              0 4 0
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   171
        05 06              0 6 0 6 0
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   172
        00 06 45 56 67 00  4 5 5 6 6 7
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   173
        04 78              7 8 7 8
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   174
        00 02 05 01        Move 5 right and 1 up. (Windows docs say down, which is wrong)
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   175
        00 00              End-of-line
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   176
        09 1E              1 E 1 E 1 E 1 E 1
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   177
        00 01              EndofBitmap
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   178
        00 00              Zero padding for 32bit boundary
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   179
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   180
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   181
Raster Data compression for 8bit / 256 color images:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   182
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   183
       BitCount = 8 Compression = 1  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   184
       The pixel data is stored in 2bytes / 16bit chunks.  The first of these specifies the number of consecutive pixels with the
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   185
       same color. The second byte defines their color index. If the first byte is zero, the second defines an escape code. The
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   186
       End-of-Bitmap is zero padded to end on a 32bit boundary. Due to the 16bit-ness of this structure this will always be
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   187
       either two zero bytes or none.   
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   188
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   189
        n (byte 1)   c (Byte 2)                                    Description
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   190
        >0       any        n pixels of color number c
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   191
        0        0          End-of-line
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   192
        0        1          End Of Bitmap
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   193
        0        2          Delta. The following 2 bytes define an unsigned offset in x and y direction (y being up) The
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   194
                            skipped pixels should get a color zero.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   195
        0        >=3        The following c bytes will be read as single pixel colors just as in uncompressed files. A zero
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   196
                            follows, if c is odd, putting the file/memory pointer on a 16bit boundary again.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   197
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   198
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   199
                                      Example for 8bit RLE
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   200
        Compressed Data                           Expanded data
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   201
        03 04              04 04 04
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   202
        05 06              06 06 06 06 06
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   203
        00 03 45 56 67 00  45 56 67
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   204
        02 78              78 78
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   205
        00 02 05 01        Move 5 right and 1 up. (Windows docs say down, which is wrong)
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   206
        00 00              End-of-line
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   207
        09 1E              1E 1E 1E 1E 1E 1E 1E 1E 1E
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   208
        00 01              End-of-bitmap
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   209
        00 00              Zero padding for 32bit boundary
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   210
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   211
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   212
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   213
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   214
Portability:
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   215
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   216
       Although BMPs were invented by Microsoft for its Windows platform, a lot of programs on other platforms are capable
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   217
       of reading and writing them. Notice the Intel order in 2byte and 4-byte integer values (Least significant byte first). The
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   218
       16bit BMPs have been introduced to Windows after the others, still puzzling many applications.
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   219
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   220
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   221
Trademarks, Patents and Royalties
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   222
       To my knowledge: None.  
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   223
"
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
   224
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   225
! !
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   226
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   227
!WindowsIconReader class methodsFor:'initialization'!
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   228
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   229
initialize
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   230
    "tell Image-class, that a new fileReader is present
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
   231
     for the '.bmp' and '.ico' extensions."
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   232
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   233
    MIMETypes defineImageType:'image/x-MS-bitmap' suffix:'bmp' reader:self.
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   234
    MIMETypes defineImageType:nil                 suffix:'ico' reader:self.
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   235
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
   236
    "Modified: 1.2.1997 / 15:03:59 / cg"
28
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   237
! !
8daff0234d2e *** empty log message ***
claus
parents: 24
diff changeset
   238
102
claus
parents: 99
diff changeset
   239
!WindowsIconReader class methodsFor:'testing'!
claus
parents: 99
diff changeset
   240
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   241
canRepresent:anImage
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   242
    "return true, if anImage can be represented in my file format.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   243
     BMP supports depth 1,4,8 and 24."
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   244
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   245
    ^ (#(1 4 8 24) includes:anImage depth)
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   246
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   247
    "Created: 17.10.1997 / 20:18:23 / cg"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   248
!
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   249
102
claus
parents: 99
diff changeset
   250
isValidImageFile:aFileName
claus
parents: 99
diff changeset
   251
    "return true, if aFileName contains a valid windows bitmap-file image"
claus
parents: 99
diff changeset
   252
claus
parents: 99
diff changeset
   253
    |inStream header ok|
claus
parents: 99
diff changeset
   254
claus
parents: 99
diff changeset
   255
    inStream := self streamReadingFile:aFileName.
claus
parents: 99
diff changeset
   256
    inStream isNil ifTrue:[^ false].
claus
parents: 99
diff changeset
   257
claus
parents: 99
diff changeset
   258
    inStream binary.
104
claus
parents: 103
diff changeset
   259
    ok := false.
692
e6af4c70e066 size is going to be eliminated from the stream
Claus Gittinger <cg@exept.de>
parents: 678
diff changeset
   260
    inStream fileSize > 16 ifTrue:[
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   261
        header := ByteArray uninitializedNew:4.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   262
        inStream nextBytes:4 into:header.
102
claus
parents: 99
diff changeset
   263
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   264
        (header startsWith:#(66 77)) ifTrue:[     "BM"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   265
            ok := true.
104
claus
parents: 103
diff changeset
   266
"/            'WINREADER: Win3.x or OS/2 vsn 2 BM format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   267
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   268
        (header startsWith:#(66 65)) ifTrue:[     "BA"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   269
            ok := true.
104
claus
parents: 103
diff changeset
   270
"/            'WINREADER: OS/2 vsn 2 BA format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   271
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   272
        (header startsWith:#(73 67)) ifTrue:[     "IC"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   273
            ok := true.
104
claus
parents: 103
diff changeset
   274
"/            'WINREADER: OS/2 IC format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   275
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   276
        (header startsWith:#(80 84)) ifTrue:[     "PT"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   277
            ok := true.
104
claus
parents: 103
diff changeset
   278
"/            'WINREADER: OS/2 PT format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   279
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   280
        (header startsWith:#(0 0 1 0)) ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   281
            ok := true.
104
claus
parents: 103
diff changeset
   282
"/            'WINREADER: Win3.x ICO format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   283
        ].
102
claus
parents: 99
diff changeset
   284
    ].
104
claus
parents: 103
diff changeset
   285
    inStream close.
claus
parents: 103
diff changeset
   286
    ^ ok
102
claus
parents: 99
diff changeset
   287
claus
parents: 99
diff changeset
   288
    "
claus
parents: 99
diff changeset
   289
     WindowsIconReader isValidImageFile:'/phys/clam2/LocalLibrary/Images/OS2_icons/dos.ico'
claus
parents: 99
diff changeset
   290
    "
claus
parents: 99
diff changeset
   291
claus
parents: 99
diff changeset
   292
    "Created: 17.9.1995 / 17:14:20 / claus"
claus
parents: 99
diff changeset
   293
! !
claus
parents: 99
diff changeset
   294
103
claus
parents: 102
diff changeset
   295
!WindowsIconReader methodsFor:'private'!
claus
parents: 102
diff changeset
   296
claus
parents: 102
diff changeset
   297
loadBMPWidth:w height:h depth:d compression:c from:aStream into:data
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   298
    "helper: load a BMP image"
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   299
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   300
    |buff idx fileBytesPerRow imgBytesPerRow|
160
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   301
103
claus
parents: 102
diff changeset
   302
    d == 8 ifTrue:[
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   303
        (self class loadBMP8Width:w height:h compression:c from:aStream into:data) ifFalse:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   304
            self fileFormatError:'read/decompression failed'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   305
            ^ false
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   306
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   307
        ^ true
160
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   308
    ].
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   309
    d == 4 ifTrue:[
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   310
        (self class loadBMP4to8Width:w height:h compression:c from:aStream into:data) ifFalse:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   311
            self fileFormatError:'read/decompression failed'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   312
            ^ false
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   313
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   314
        ^ true
160
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   315
    ].
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   316
    d == 2 ifTrue:[
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   317
        (self class loadBMP2to8Width:w height:h from:aStream into:data) ifFalse:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   318
            self fileFormatError:'read failed'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   319
            ^ false
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   320
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   321
        ^ true
103
claus
parents: 102
diff changeset
   322
    ].
160
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   323
    d == 1 ifTrue:[
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   324
        (self class loadBMP1to8Width:w height:h from:aStream into:data) ifFalse:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   325
            self fileFormatError:'read failed'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   326
            ^ false
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   327
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   328
        ^ true
160
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   329
    ].
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   330
    d == 24 ifTrue:[
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   331
        imgBytesPerRow := w * 3.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   332
        fileBytesPerRow := imgBytesPerRow.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   333
        (fileBytesPerRow bitAnd:3) ~~ 0 ifTrue:[
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   334
            fileBytesPerRow := (fileBytesPerRow bitAnd:(3 bitInvert)) + 4.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   335
        ].
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   336
        "/
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   337
        "/ stupid - last row comes first
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   338
        "/
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   339
        idx := imgBytesPerRow * (height - 1) + 1.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   340
        buff := ByteArray uninitializedNew:fileBytesPerRow.
160
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   341
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   342
        1 to:height do:[:row |
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   343
            (aStream nextBytes:fileBytesPerRow into:buff) ~~ fileBytesPerRow ifTrue:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   344
                self fileFormatError:'read failed'.
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   345
                ^ false
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   346
            ].
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   347
            data replaceFrom:idx to:idx+imgBytesPerRow-1 with:buff.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   348
            idx := idx - imgBytesPerRow.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   349
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   350
        ^ true
160
ee4d64b12c94 handle depth 24 rgb BMP files
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   351
    ].
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   352
    self fileFormatError:('unsupported depth:' , d printString).
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   353
    ^ false
103
claus
parents: 102
diff changeset
   354
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   355
    "Created: / 17.9.1995 / 18:48:11 / claus"
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   356
    "Modified: / 3.2.1998 / 20:21:16 / cg"
103
claus
parents: 102
diff changeset
   357
! !
claus
parents: 102
diff changeset
   358
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1790
diff changeset
   359
!WindowsIconReader methodsFor:'reading'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   360
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   361
fromOS2File:aFilename
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   362
    "read an image from an OS/2 BMP file"
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   363
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   364
    |reader stream|
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   365
1790
41f36b5a29c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   366
    stream := self class streamReadingFile:aFilename.
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   367
    stream isNil ifTrue:[^ nil].
1790
41f36b5a29c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   368
    reader := (self class new) fromOS2Stream:stream.
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   369
    stream close.
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   370
    reader notNil ifTrue:[^ reader image].
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   371
    ^ nil
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   372
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   373
    "Modified: 23.4.1996 / 13:09:28 / cg"
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   374
!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   375
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   376
fromOS2Stream:aStream
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   377
    "read an image from an OS/2 BMP stream"
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   378
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   379
    |header inDepth inBytesPerRow mask bytesPerRow nColors nByte|
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   380
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   381
    inStream := aStream.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   382
    aStream binary.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   383
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   384
    "read the header"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   385
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   386
    header := ByteArray uninitializedNew:8r110.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   387
    aStream nextBytes:16 into:header.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   388
445
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   389
    (header startsWith:#(73 67)) ifTrue:[         "IC"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   390
        "IC format"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   391
        aStream nextBytes:10 into:header startingAt:17.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   392
        width := header at:7.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   393
        height := header at:9.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   394
        inDepth := 2 "header at:11". "where is it"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   395
    ] ifFalse:[
445
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   396
        (header startsWith:#(67 73)) ifTrue:[     "CI"
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   397
            ^ self fileFormatError:'unsupported format: CI'.
445
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   398
        ] ifFalse:[
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   399
            aStream nextBytes:(8r110-16) into:header startingAt:17.
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   400
            width := header at:8r101.
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   401
            height := header at:8r103.
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   402
            inDepth := header at:8r107.
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   403
        ]
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   404
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   405
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   406
    "read the colormap; notice: its in BGR order (sigh)"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   407
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   408
    nColors := 1 bitShift:inDepth.
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   409
    colorMap := self readColorMap:nColors numBytesPerColor:3 from:aStream.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   410
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   411
    "read the mask"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   412
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   413
    nByte := width * height + 7 // 8.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   414
    mask := ByteArray uninitializedNew:nByte.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   415
    aStream nextBytes:nByte into:mask.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   416
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   417
    "what is this ?"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   418
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   419
    aStream nextBytes:nByte into:mask.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   420
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   421
"/    "read the data bits"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   422
"/
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   423
"/    bytesPerRow := width * inDepth + 7 // 8.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   424
"/    data4 := ByteArray uninitializedNew:(height * bytesPerRow).
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   425
"/    inDepth == 8 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   426
"/    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   427
"/    aStream nextBytes:(height * bytesPerRow) into:data4.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   428
"/
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   429
"/    "stupid: last row first"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   430
"/
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   431
"/    tmp := ByteArray new:(height * bytesPerRow).
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   432
"/    srcIndex := 1.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   433
"/    dstIndex := (height - 1) * bytesPerRow + 1.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   434
"/    1 to:height do:[:row |
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   435
"/        tmp replaceFrom:dstIndex to:(dstIndex + bytesPerRow - 1)
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   436
"/                   with:data4 startingAt:srcIndex.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   437
"/        srcIndex := srcIndex + bytesPerRow.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   438
"/        dstIndex := dstIndex - bytesPerRow.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   439
"/    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   440
"/    data4 := tmp.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   441
"/
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   442
"/    "expand into bytes"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   443
"/
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   444
"/    data := ByteArray new:(width * height).
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   445
"/    data4 expandPixels:inDepth width:width height:height
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   446
"/                  into:data mapping:nil.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   447
"/
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   448
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   449
    bytesPerRow := width * inDepth + 7 // 8.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   450
    "/ bmp data is always 32bit aligned; if required,
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   451
    inBytesPerRow := ((bytesPerRow + 3) // 4) * 4.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   452
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   453
    data := ByteArray uninitializedNew:(height * width "bytesPerRow").
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   454
    (self loadBMPWidth:width height:height depth:inDepth compression:0 from:aStream into:data) ifFalse:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   455
        ^ nil
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   456
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   457
    photometric := #palette.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   458
    samplesPerPixel := 1.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   459
    bitsPerSample := #(8).
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   460
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   461
    "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   462
     |i f|
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   463
     i := Image fromFile:'/LocalLibrary/Images/OS2/dos3.ico'.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   464
     f := i asFormOn:Display.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   465
     v displayOpaqueForm:(f magnifyBy:2@2) x:5 y:5
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   466
    "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   467
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   468
    "Modified: / 17.9.1995 / 18:49:24 / claus"
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   469
    "Modified: / 3.2.1998 / 20:17:13 / cg"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   470
!
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   471
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   472
fromStream:aStream 
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   473
    "figure out which format the stream contains
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   474
     (there are various different bmp/ico formats around)
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   475
     and read the image."
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   476
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   477
    |fileSize header|
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   478
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   479
    inStream := aStream.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   480
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   481
    aStream binary.
692
e6af4c70e066 size is going to be eliminated from the stream
Claus Gittinger <cg@exept.de>
parents: 678
diff changeset
   482
    fileSize := aStream fileSize.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   483
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   484
    fileSize < 16 ifTrue:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   485
        ^ self fileFormatError:'short file'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   486
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   487
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   488
    header := ByteArray uninitializedNew:4.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   489
    aStream nextBytes:4 into:header.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   490
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   491
    (header startsWith:#(66 77)) ifTrue:[     "BM"
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   492
        aStream position1Based:1.
387
0f4c8ef0e973 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   493
"/        'WinIconReader [info]: Win3.x or OS/2 vsn 2 BM format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   494
        ^ self fromWindowsBMPStream:aStream
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   495
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   496
    (header startsWith:#(66 65)) ifTrue:[     "BA"
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   497
        aStream position1Based:1.
387
0f4c8ef0e973 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   498
"/        'WinIconReader [info]: OS/2 vsn 2 BA format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   499
        ^ self fromOS2Stream:aStream
445
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   500
    ].                    
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   501
    (header startsWith:#(67 73)) ifTrue:[     "CI"
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   502
        'WinIconReader [warning]: OS/2 CI format not supported:' infoPrintCR.
445
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   503
        ^ nil.
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   504
        aStream position1Based:1.
445
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   505
"/        'WinIconReader [info]: OS/2 vsn 2 BA format' infoPrintNL.
899af8ff2a5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   506
        ^ self fromOS2Stream:aStream
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   507
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   508
    (header startsWith:#(73 67)) ifTrue:[     "IC"
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   509
        aStream position1Based:1.
387
0f4c8ef0e973 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   510
"/        'WinIconReader [info]: OS/2 IC format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   511
        ^ self fromOS2Stream:aStream
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   512
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   513
    (header startsWith:#(80 84)) ifTrue:[     "PT"
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   514
        aStream position1Based:1.
387
0f4c8ef0e973 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   515
"/        'WinIconReader [info]: OS/2 PT format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   516
        ^ self fromOS2Stream:aStream
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   517
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   518
    (header startsWith:#(16r53 16r5A)) ifTrue:[     "SZ"
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   519
        'WinIconReader [warning]: OS/2 SZ format not supported:' infoPrintCR.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   520
        ^ nil.
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   521
"/        aStream position1Based:1.
1167
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   522
"/        'WinIconReader [info]: OS/2 SZ format' infoPrintNL.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   523
"/        ^ self fromOS2Stream:aStream
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   524
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   525
    (header startsWith:#(0 0 1 0)) ifTrue:[
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   526
        aStream position1Based:1.
387
0f4c8ef0e973 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   527
"/        'WinIconReader [info]: Win3.x ICO format' infoPrintNL.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   528
        ^ self fromWindowsICOStream:aStream
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   529
    ].
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   530
    ^ self fileFormatError:('format not supported:'
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   531
                            , ((header at:1) printStringRadix:16)
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   532
                            , ' ' 
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   533
                            , ((header at:2) printStringRadix:16)).
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   534
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   535
    "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   536
     Image fromFile:'/phys/clam//LocalLibrary/Images/OS2_icons/dos.ico'
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   537
    "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   538
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   539
    "Modified: / 17.9.1995 / 18:59:07 / claus"
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   540
    "Modified: / 3.2.1998 / 20:18:14 / cg"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   541
!
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   542
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   543
fromWindowsBMPFile: aFilename 
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   544
    "read an image from a windows BMP file"
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   545
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   546
    |reader stream|
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   547
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   548
    stream := self class streamReadingFile:aFilename.
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   549
    stream isNil ifTrue:[^ nil].
1790
41f36b5a29c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   550
    reader := (self class new) fromWindowsBMPStream:stream.
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   551
    stream close.
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   552
    reader notNil ifTrue:[^ reader image].
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   553
    ^ nil
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   554
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   555
    "Modified: 23.4.1996 / 13:09:53 / cg"
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   556
!
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   557
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   558
fromWindowsBMPStream:aStream 
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   559
    "read an image from a windows BMP stream"
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   560
518
c9d492fbb1b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
   561
    | fileSize header iSize inDepth inPlanes compression
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   562
      imgSize resH resV numColor numImportantColor
1073
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   563
      dataStart t
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   564
      bytesPerRow numBytesPerColorInColormap|
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   565
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   566
    inStream := aStream.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   567
    aStream binary.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   568
692
e6af4c70e066 size is going to be eliminated from the stream
Claus Gittinger <cg@exept.de>
parents: 678
diff changeset
   569
    fileSize := aStream fileSize.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   570
    "read the header"
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   571
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   572
    header := ByteArray uninitializedNew:16r54.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   573
    aStream nextBytes:18 into:header.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   574
518
c9d492fbb1b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
   575
    iSize := header at:(16r0E + 1).
c9d492fbb1b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
   576
    (iSize == 40) ifTrue:[    "header-size"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   577
        "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   578
         its an Windows3.x BMP file
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   579
         or OS/2 vsn 2 BMP file
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   580
        "
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   581
        "/ 'WinIconReader [info]: Win3.x or OS/2 vsn 2 format' infoPrintCR.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   582
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   583
        aStream nextBytes:(40-4) into:header startingAt:19.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   584
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   585
        width := header wordAt:(16r12 + 1) MSB:false.  "(header at:19) + ((header at:20) * 256).   "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   586
        height := header wordAt:(16r16 + 1) MSB:false. "(header at:23) + ((header at:24) * 256).   "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   587
        inPlanes := header wordAt:(16r1A + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   588
        inDepth := header wordAt:(16r1C + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   589
        compression := header wordAt:(16r1E + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   590
        imgSize := header doubleWordAt:(16r22 + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   591
        resH := header doubleWordAt:(16r26 + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   592
        resV := header doubleWordAt:(16r2A + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   593
        numColor := header doubleWordAt:(16r2E + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   594
        numImportantColor := header doubleWordAt:(16r32 + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   595
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   596
        numColor == 0 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   597
            "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   598
             some bmp-writers seem to leave this as zero (which is wrong)
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   599
            "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   600
            inDepth <= 8 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   601
                numColor := 1 bitShift:inDepth.
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   602
                "/ 'WinIconReader [warning]: missing nColor in header - assume ' infoPrint. numColor infoPrintCR
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   603
            ]
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   604
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   605
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   606
        numBytesPerColorInColormap := 4.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   607
        dataStart := header wordAt:(16r0A + 1) MSB:false
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   608
    ] ifFalse:[
518
c9d492fbb1b6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
   609
        (iSize == 12) ifTrue:[     "core-info header size"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   610
            "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   611
             its an OS/2 (vsn1.2) BMP file
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   612
            "
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   613
            "/ 'WinIconReader [info]: OS/2 vsn 1.2 format' infoPrintCR.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   614
            aStream nextBytes:(12-4) into:header startingAt:19.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   615
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   616
            width := header wordAt:(16r12 + 1) MSB:false.  "(header at:19) + ((header at:20) * 256).   "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   617
            height := header wordAt:(16r14 + 1) MSB:false. "(header at:21) + ((header at:22) * 256).   "
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   618
            inPlanes := header wordAt:(16r16 + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   619
            inDepth := header wordAt:(16r18 + 1) MSB:false.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   620
            numColor := 1 bitShift:inDepth.
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   621
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   622
            numBytesPerColorInColormap := 3.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   623
            compression := 0.
565
03b84a590f49 fixed os2 bmp reading
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   624
            "/ dataStart := header wordAt:(16r0A + 1) MSB:false.
03b84a590f49 fixed os2 bmp reading
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   625
            dataStart := nil.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   626
        ] ifFalse:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   627
            ^ self fileFormatError:'unknown format'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   628
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   629
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   630
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   631
    numColor ~~ 0 ifTrue:[
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   632
        "read the colormap - notice: its in BGR order (sigh)"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   633
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   634
        colorMap := self 
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   635
                        readColorMap:numColor 
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   636
                        numBytesPerColor:numBytesPerColorInColormap
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   637
                        from:aStream.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   638
898
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   639
        numColor > (1 bitShift:inDepth) ifTrue:[
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   640
            'funny number of colors in image' infoPrintCR.
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   641
            numColor := 1 bitShift:inDepth.
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   642
            colorMap := colorMap copyTo:numColor.
898
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   643
        ].
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   644
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   645
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   646
    "/ check for valid compression
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   647
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   648
    compression ~~ 0 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   649
        "/ some compression
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   650
        compression == 1 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   651
            "/ RLE8 - must be depth-8
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   652
            inDepth ~~ 8 ifTrue:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   653
                ^ self fileFormatError:'RLE8 compression only supported with depth8 images'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   654
            ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   655
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   656
        compression == 2 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   657
            "/ RLE4 - must be depth-4
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   658
            inDepth ~~ 4 ifTrue:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   659
                ^ self fileFormatError:'RLE4 compression only supported with depth4 images'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   660
            ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   661
        ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   662
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   663
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   664
    inPlanes ~~ 1 ifTrue:[
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   665
        ^ self fileFormatError:'only 1 plane images supported'.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   666
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   667
565
03b84a590f49 fixed os2 bmp reading
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   668
    dataStart notNil ifTrue:[
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   669
        aStream position1Based:(dataStart + 1).
565
03b84a590f49 fixed os2 bmp reading
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
   670
    ].
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   671
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   672
    inDepth == 24 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   673
        bytesPerRow := width * 3
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   674
    ] ifFalse:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   675
        bytesPerRow := width
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   676
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   677
    data := ByteArray uninitializedNew:(height * bytesPerRow).
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   678
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   679
    "/ read & possibly decompress
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   680
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   681
    (self loadBMPWidth:width height:height depth:inDepth compression:compression from:aStream into:data) ifFalse:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   682
        ^ nil
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   683
    ].
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   684
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   685
    inDepth == 24 ifTrue:[
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   686
        photometric := #rgb.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   687
        samplesPerPixel := 3.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   688
        bitsPerSample := #(8 8 8).
1073
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   689
        "/ stupid must swap red & blue bytes
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   690
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   691
        1 to:data size by:3 do:[:i |
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   692
            t := data at:i.
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   693
            data at:i put:(data at:i+2).
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   694
            data at:i+2 put:t
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   695
        ].
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   696
        ^ self
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   697
    ].
898
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   698
    inDepth == 1 ifTrue:[
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   699
        photometric := #blackIs0.
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   700
        samplesPerPixel := 1.
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   701
        bitsPerSample := #(1).
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   702
        ^ self
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   703
    ].
899
a2676b9f61ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   704
    (inDepth ~~ 8) ifTrue:[
a2676b9f61ba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
   705
        "/ self halt:'unsupported depth'.
898
cdf6cc132b53 care for funny number of colors (nColor > (1<<depth))
Claus Gittinger <cg@exept.de>
parents: 819
diff changeset
   706
    ].
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   707
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   708
    photometric := #palette.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   709
    samplesPerPixel := 1.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   710
    bitsPerSample := #(8).
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   711
819
e358c08e45ea common error reporter
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   712
    "Modified: / 17.9.1995 / 18:48:46 / claus"
1073
1e1450185eb8 fixed r-g-b order (red & blue are swapped in file)
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   713
    "Modified: / 16.9.1998 / 01:09:08 / cg"
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   714
!
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   715
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   716
fromWindowsICOFile:aFilename 
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   717
    "read an image from a windows ICO file"
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   718
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   719
    |reader stream|
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   720
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   721
    stream := self class streamReadingFile:aFilename.
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   722
    stream isNil ifTrue:[^ nil].
1790
41f36b5a29c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1759
diff changeset
   723
    reader := (self class new) fromWindowsICOStream:stream.
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   724
    stream close.
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   725
    reader notNil ifTrue:[^ reader image].
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   726
    ^ nil
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   727
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   728
    "
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   729
     Image fromFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   730
    "
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   731
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   732
    "Modified: 23.4.1996 / 13:10:11 / cg"
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   733
!
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   734
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   735
fromWindowsICOStream:aStream
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   736
    "read an image from a windows ICO stream"
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   737
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   738
    |header inDepth
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   739
     srcIndex dstIndex
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   740
     rawData tmp bytesPerRow nColor cmapSize|
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   741
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   742
    inStream := aStream.
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   743
    aStream binary.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   744
3f9277473954 Initial revision
claus
parents:
diff changeset
   745
    "read the header"
3f9277473954 Initial revision
claus
parents:
diff changeset
   746
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   747
    header := ByteArray uninitializedNew:(6 + 16 + 40).
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   748
    aStream nextBytes:(6 + 16 + 40) into:header.
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   749
    width := header at:(6+1).
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   750
    height := header at:(7+1).
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   751
    nColor := header at:(8+1).
430
50b841f4851d commentary
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   752
    "/ reserved := header at:(9+1).
50b841f4851d commentary
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   753
    "/ nPlanes := header wordAt:(10+1).
50b841f4851d commentary
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   754
    "/ nBitsPerPel := header wordAt:(12+1).
50b841f4851d commentary
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   755
    "/ nBytesInResource := header doubleWordAt:(14+1).
50b841f4851d commentary
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   756
    "/ ordinal := header wordAt:(18+1).
50b841f4851d commentary
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   757
    "21, 22               ?"
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   758
    "23, ... , 62         ?"
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   759
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   760
    inDepth := header at:16r25.
1386
2d02a4fba456 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   761
    "/ mhmh - some depth4 icons seem to have a 0 in the depth field ...
2d02a4fba456 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   762
    inDepth == 0 ifTrue:[
2d02a4fba456 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   763
        inDepth := 4
2d02a4fba456 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1385
diff changeset
   764
    ].
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   765
    (#(4 8) includes:inDepth) ifFalse:[
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   766
        "/ only tested for depth 4/8 images.
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   767
        ^ self fileFormatError:'only depth 4/8 ico-images supported (depth is ' , inDepth printString , ')'.
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   768
"/        self halt:'only depth 4 ico-images supported (depth is ' , inDepth printString , ')'.
1171
d848c46349ab sorry: only depth4 images are handled.
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   769
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   770
3f9277473954 Initial revision
claus
parents:
diff changeset
   771
    "read the colormap"
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   772
    cmapSize := (1 bitShift:inDepth).
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   773
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   774
    colorMap := self
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   775
                readColorMap:cmapSize
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   776
                numBytesPerColor:4
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   777
                from:aStream.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   778
3f9277473954 Initial revision
claus
parents:
diff changeset
   779
    "read the data bits"
3f9277473954 Initial revision
claus
parents:
diff changeset
   780
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   781
    bytesPerRow := width * inDepth + 7 // 8.
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   782
    rawData := ByteArray uninitializedNew:(height * bytesPerRow).
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   783
    aStream nextBytes:(height * bytesPerRow) into:rawData.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   784
3f9277473954 Initial revision
claus
parents:
diff changeset
   785
    "read mask"
3f9277473954 Initial revision
claus
parents:
diff changeset
   786
3f9277473954 Initial revision
claus
parents:
diff changeset
   787
"
3f9277473954 Initial revision
claus
parents:
diff changeset
   788
    mask := ByteArray new:(width * height / 8).
41
66edc847b9c8 *** empty log message ***
claus
parents: 36
diff changeset
   789
    aStream nextBytes:(width * height / 8) into:mask.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   790
"
3f9277473954 Initial revision
claus
parents:
diff changeset
   791
3f9277473954 Initial revision
claus
parents:
diff changeset
   792
    "stupid: last row first"
3f9277473954 Initial revision
claus
parents:
diff changeset
   793
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   794
    tmp := ByteArray uninitializedNew:(height * bytesPerRow).
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   795
    srcIndex := 1.
3f9277473954 Initial revision
claus
parents:
diff changeset
   796
    dstIndex := (height - 1) * bytesPerRow + 1.
3f9277473954 Initial revision
claus
parents:
diff changeset
   797
    1 to:height do:[:row |
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   798
        tmp replaceFrom:dstIndex to:(dstIndex + bytesPerRow - 1)
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   799
                   with:rawData startingAt:srcIndex.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   800
        srcIndex := srcIndex + bytesPerRow.
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   801
        dstIndex := dstIndex - bytesPerRow.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   802
    ].
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   803
    rawData := tmp.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   804
3f9277473954 Initial revision
claus
parents:
diff changeset
   805
    photometric := #palette.
3f9277473954 Initial revision
claus
parents:
diff changeset
   806
    samplesPerPixel := 1.
298
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   807
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   808
    false ifTrue:[
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   809
        "expand into bytes"
298
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   810
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   811
        data := ByteArray new:(width * height).
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   812
        rawData expandPixels:inDepth width:width height:height
298
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   813
                      into:data mapping:nil.
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   814
        bitsPerSample := #(8).
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   815
    ] ifFalse:[
1569
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   816
        data := rawData.
3954e576ff38 support depth 8 ico files
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
   817
        bitsPerSample := (Array with:inDepth).
298
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   818
    ].
cd59c474524a return .ico files as Depth4Images (not Depth8)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   819
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   820
    "
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   821
     WindowsIconReader new fromWindowsICOFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   822
    "
211
3eb140e89e2e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
   823
1171
d848c46349ab sorry: only depth4 images are handled.
Claus Gittinger <cg@exept.de>
parents: 1168
diff changeset
   824
    "Modified: / 18.5.1999 / 15:40:00 / cg"
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1790
diff changeset
   825
! !
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1790
diff changeset
   826
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1790
diff changeset
   827
!WindowsIconReader methodsFor:'reading-private'!
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   828
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   829
readColorMap:nColors numBytesPerColor:nRawBytesPerColor from:aStream
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   830
    "read the colormap; notice: its in BGR order (sigh)."
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   831
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   832
    |rawMap rMap gMap bMap 
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   833
     srcIndex  "{ Class: SmallInteger }"
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   834
     skipDelta "{ Class: SmallInteger }"|
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   835
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   836
    rawMap := ByteArray uninitializedNew:(nColors*nRawBytesPerColor).
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   837
    aStream nextBytes:(nColors*nRawBytesPerColor) into:rawMap.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   838
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   839
    rMap := ByteArray new:nColors.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   840
    gMap := ByteArray new:nColors.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   841
    bMap := ByteArray new:nColors.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   842
    srcIndex := 1.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   843
    skipDelta := nRawBytesPerColor - 3.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   844
1759
f52382e5a9b8 slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents: 1754
diff changeset
   845
    "/ stupid: this is a BGR-ordered map (otherwise, could use #rgbBytesVector:-message)
f52382e5a9b8 slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents: 1754
diff changeset
   846
    "/ also, there might be a fourth byte (alpha ?) which is (currently) skipped.
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   847
    1 to:nColors do:[:i |
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   848
        bMap at:i put:(rawMap at:srcIndex).
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   849
        srcIndex := srcIndex + 1.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   850
        gMap at:i put:(rawMap at:srcIndex).
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   851
        srcIndex := srcIndex + 1.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   852
        rMap at:i put:(rawMap at:srcIndex).
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   853
        srcIndex := srcIndex + 1.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   854
        srcIndex := srcIndex + skipDelta.
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   855
    ].
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   856
1759
f52382e5a9b8 slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents: 1754
diff changeset
   857
    ^ MappedPalette 
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   858
        redVector:rMap 
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   859
        greenVector:gMap 
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   860
        blueVector:bMap.
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   861
! !
21
66b31c91177f *** empty log message ***
claus
parents: 18
diff changeset
   862
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1790
diff changeset
   863
!WindowsIconReader methodsFor:'writing'!
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   864
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   865
save:image onFile:aFileName
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   866
    "save image as BMP file on aFileName.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   867
     Only depth 1,4,8 and 24 images can be represented in this format."
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   868
1168
590e5660f69e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   869
    aFileName asFilename suffix asLowercase = 'ico' ifTrue:[
590e5660f69e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   870
"/        (image depth == 4
590e5660f69e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   871
"/        and:[image width == 32
590e5660f69e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   872
"/        and:[image height == 32]]) ifTrue:[
590e5660f69e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   873
            ^ self saveICO:image onFile:aFileName.
590e5660f69e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   874
"/        ]
590e5660f69e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   875
    ].
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   876
    self saveBMP:image onFile:aFileName.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   877
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   878
    "Modified: 17.10.1997 / 20:16:53 / cg"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   879
!
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   880
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   881
saveBMP:image onFile:fileName 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   882
    "save image as BMP file on aFileName.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   883
     Only depth 1,4,8 and 24 images can be represented in this format."
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   884
1507
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   885
    |depth bhSize biSize biClrUsed biSizeImage bfOffBits rowBytes imgBytesPerRow data srcIndex row t|
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   886
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   887
    depth := image depth.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   888
    width := image width.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   889
    height := image height.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   890
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   891
    (#(1 4 8 24) includes:depth) ifFalse:[
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   892
        ^ Image cannotRepresentImageSignal 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   893
            raiseWith:image
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   894
            errorString:('BMP format only supports depths 1,4,8 and 24').
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   895
    ].
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   896
    image mask notNil ifTrue:[
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   897
        Image informationLostQuerySignal
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   898
            raiseWith:image
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   899
            errorString:('BMP format does not support an imageMask').
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   900
    ].
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   901
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   902
    bhSize := 14.  "# bytes in file header"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   903
    biSize := 40.  "info header size in bytes" 
1734
290f382d40e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1569
diff changeset
   904
    biClrUsed := (depth >= 24) ifTrue:[0] ifFalse:[1 bitShift: depth].  "No. color table entries"
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   905
    bfOffBits := biSize + bhSize + (4*biClrUsed).
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   906
    "/ bmp aligns rows on a longword boundary
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   907
    rowBytes := ((depth min:24) * width + 31 // 32) * 4.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   908
    biSizeImage := height * rowBytes.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   909
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   910
    outStream := fileName asFilename writeStream.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   911
    outStream binary.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   912
    byteOrder := #lsb.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   913
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   914
    "Write the file header"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   915
    self writeShort:19778.  "bfType = BM" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   916
    self writeLong:(bfOffBits + biSizeImage).  "Entire file size in bytes"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   917
    self writeLong:0.  "bfReserved" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   918
    self writeLong:bfOffBits.  "Offset of bitmap data from start of hdr (and file)"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   919
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   920
    "Write the bitmap info header"
1754
cc844dc3504e avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   921
    outStream position1Based: bhSize+1.
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   922
    self writeLong:biSize.  "info header size in bytes" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   923
    self writeLong:width.  "biWidth" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   924
    self writeLong:height.  "biHeight" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   925
    self writeShort:1.  "biPlanes" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   926
    self writeShort:(depth min:24).  "biBitCount" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   927
    self writeLong:0.  "biCompression" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   928
    self writeLong:biSizeImage.  "size of image section in bytes"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   929
    self writeLong:2800.  "biXPelsPerMeter" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   930
    self writeLong:2800.  "biYPelsPerMeter" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   931
    self writeLong:biClrUsed.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   932
    self writeLong:0.  "biClrImportant" 
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   933
    1 to:biClrUsed do:[:i |  "Color map"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   934
        |clr r g b|
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   935
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   936
        clr := image colorFromValue:i-1.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   937
        clr isNil ifTrue:[
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   938
            r := g := b := 0.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   939
        ] ifFalse:[
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   940
            r := clr redByte.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   941
            g := clr greenByte.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   942
            b := clr blueByte.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   943
        ].
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   944
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   945
        "/ put B,G,R
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   946
        outStream nextPut:b.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   947
        outStream nextPut:g.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   948
        outStream nextPut:r.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   949
        outStream nextPut:0.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   950
    ].
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   951
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   952
    imgBytesPerRow := image bytesPerRow.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   953
    data := image data.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   954
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   955
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   956
    "/ sorry, must extract rows individually
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   957
    "/ (even if alignment is correct),
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   958
    "/ since BMP saves rows bottom-to-top
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   959
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   960
    row := ByteArray new:rowBytes.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   961
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   962
    srcIndex := 1 + (height * imgBytesPerRow).
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   963
    1 to:height do:[:i |
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   964
        srcIndex := srcIndex - imgBytesPerRow.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   965
        row replaceFrom:1 to:imgBytesPerRow with:data startingAt:srcIndex.
1507
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   966
        depth >= 24 ifTrue:[
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   967
            "/ stupid must swap red & blue bytes
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   968
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   969
            1 to:row size by:3 do:[:i |
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   970
                t := row at:i.
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   971
                row at:i put:(row at:i+2).
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   972
                row at:i+2 put:t
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   973
            ].
9bae072abf64 fixed bmp saving 24bit image (red & blue channels exchanged)
Claus Gittinger <cg@exept.de>
parents: 1386
diff changeset
   974
        ].
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   975
        outStream nextPutAll:row.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   976
    ].
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   977
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   978
    outStream close.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   979
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   980
    "
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   981
     |i|
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   982
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   983
     i := Image fromFile:'bitmaps/SBrowser.xbm'.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   984
     WindowsIconReader save:i onFile:'test.bmp'.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   985
    "
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   986
    "
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   987
     |i|
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   988
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   989
     i := Image fromFile:'bitmaps/gifImages/garfield.gif'.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   990
     WindowsIconReader save:i onFile:'test.bmp'.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   991
    "
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   992
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   993
    "Modified: 21.10.1997 / 05:02:02 / cg"
1167
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   994
!
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   995
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   996
saveICO:image onFile:fileName 
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   997
    "save image as ICO file on aFileName.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   998
     Only depth 4 images of size 32x32 can be represented in this format."
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
   999
1233
6587cabeab10 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1171
diff changeset
  1000
    |depth biSizeImage rowBytes imgBytesPerRow data srcIndex row|
1167
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1001
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1002
    depth := image depth.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1003
    width := image width.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1004
    height := image height.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1005
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1006
    depth ~~ 4 ifTrue:[
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1007
        ^ Image cannotRepresentImageSignal 
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1008
            raiseWith:image
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1009
            errorString:('ICO format only supports depths 4').
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1010
    ].
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1011
    (width ~~ 32 or:[height ~~ 32]) ifTrue:[
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1012
        ^ Image cannotRepresentImageSignal 
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1013
            raiseWith:image
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1014
            errorString:('ICO format (currently) only supports 32x32 bitmaps').
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1015
    ].
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1016
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1017
    "/ align rows on a longword boundary
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1018
    rowBytes := (depth * width + 31 // 32) * 4.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1019
    biSizeImage := height * rowBytes.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1020
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1021
    outStream := fileName asFilename writeStream.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1022
    outStream binary.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1023
    byteOrder := #lsb.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1024
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1025
    "Write the file header"
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1026
    outStream nextPutAll:#[0 0 1 0].    "/ ICO magic
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1027
    self writeShort:1.             "/ # of images in file
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1028
    outStream nextPut:image width.      "/
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1029
    outStream nextPut:image height.     "/
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1030
    outStream nextPut:(1 bitShift:image depth). "/ # of colors
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1031
    outStream nextPutAll:#[0 0 0 0 0 ]. "/ reserved
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1032
    self writeLong:16rE802.              "/ size pixels
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1033
    self writeLong:16r26.                "/ offset in file
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1034
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1035
    "/ 40 bytes - unknown format
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1036
    outStream nextPutAll:(ByteArray new:40).
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1037
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1038
    "/ 16-entry RGB map
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1039
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1040
    1 to:16 do:[:i |  "Color map"
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1041
        |clr r g b|
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1042
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1043
        clr := image colorFromValue:i-1.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1044
        clr isNil ifTrue:[
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1045
            r := g := b := 0.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1046
        ] ifFalse:[
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1047
            r := clr redByte.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1048
            g := clr greenByte.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1049
            b := clr blueByte.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1050
        ].
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1051
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1052
        "/ put B,G,R
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1053
        outStream nextPut:b.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1054
        outStream nextPut:g.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1055
        outStream nextPut:r.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1056
        outStream nextPut:0.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1057
    ].
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1058
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1059
    imgBytesPerRow := image bytesPerRow.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1060
    data := image data.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1061
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1062
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1063
    "/ sorry, must extract rows individually
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1064
    "/ (even if alignment is correct),
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1065
    "/ since ICO saves rows bottom-to-top
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1066
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1067
    row := ByteArray new:rowBytes.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1068
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1069
    srcIndex := 1 + (height * imgBytesPerRow).
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1070
    1 to:height do:[:i |
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1071
        srcIndex := srcIndex - imgBytesPerRow.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1072
        row replaceFrom:1 to:imgBytesPerRow with:data startingAt:srcIndex.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1073
        outStream nextPutAll:row.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1074
    ].
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1075
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1076
    "/ the mask ...
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1077
    image mask isNil ifTrue:[
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1078
        outStream next:128 put:16rFF
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1079
    ] ifFalse:[
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1080
        imgBytesPerRow := image mask bytesPerRow.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1081
        data := image mask data.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1082
        row := ByteArray new:4.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1083
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1084
        srcIndex := 1 + (height * imgBytesPerRow).
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1085
        1 to:height do:[:i |
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1086
            srcIndex := srcIndex - imgBytesPerRow.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1087
            row replaceFrom:1 to:imgBytesPerRow with:data startingAt:srcIndex.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1088
            outStream nextPutAll:row.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1089
        ].
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1090
    ].
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1091
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1092
    outStream close.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1093
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1094
    "
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1095
     |i|
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1096
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1097
     i := Image fromFile:'bitmaps/xpmBitmaps/SmalltalkX_clr.xpm'.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1098
     i := Depth4Image fromImage:i.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1099
     i := i magnifiedTo:32@32.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1100
     WindowsIconReader new saveICO:i onFile:'test.ico'.
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1101
    "
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1102
78084516ae7c first attempt in saving ICO files.
Claus Gittinger <cg@exept.de>
parents: 1073
diff changeset
  1103
    "Modified: 21.10.1997 / 05:02:02 / cg"
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
  1104
! !
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
  1105
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
  1106
!WindowsIconReader class methodsFor:'documentation'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1107
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
  1108
version
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1790
diff changeset
  1109
    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.56 2003-09-01 14:47:47 cg Exp $'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1110
! !
1734
290f382d40e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1569
diff changeset
  1111
172
ee7d84977c86 use inforPrint instead of errorPrint (these are not fatal errors)
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
  1112
WindowsIconReader initialize!