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