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