314 "Modified: / 18.3.1999 / 11:32:46 / cg" |
314 "Modified: / 18.3.1999 / 11:32:46 / cg" |
315 ! ! |
315 ! ! |
316 |
316 |
317 !XBMReader methodsFor:'writing'! |
317 !XBMReader methodsFor:'writing'! |
318 |
318 |
319 save:image onFile:aFileName |
|
320 "save image as XBM file on aFileName. |
|
321 Only depth1 b&w images can be represented in this format." |
|
322 |
|
323 |stream| |
|
324 |
|
325 "sigh - must check before creating file" |
|
326 (self class canRepresent:image) ifFalse:[ |
|
327 ^ Image cannotRepresentImageSignal |
|
328 raiseWith:image |
|
329 errorString:('XBM format only supports monochrome images'). |
|
330 ]. |
|
331 |
|
332 image mask notNil ifTrue:[ |
|
333 Image informationLostQuerySignal |
|
334 raiseWith:image |
|
335 errorString:('XBM format does not support an imageMask'). |
|
336 ]. |
|
337 |
|
338 [ |
|
339 stream := aFileName asFilename newReadWriteStream. |
|
340 ] on:FileStream openErrorSignal do:[:ex| |
|
341 ^ Image fileCreationErrorSignal |
|
342 raiseWith:image |
|
343 errorString:('file creation error: ' , aFileName asString). |
|
344 ]. |
|
345 |
|
346 self save:image onStream:stream. |
|
347 stream close |
|
348 |
|
349 " |
|
350 XBMReader save:(Image fromFile:'../../goodies/bitmaps/xbmBitmaps/TicTacToe.xbm') onFile:'/tmp/test.xbm' |
|
351 " |
|
352 " |
|
353 convert sun icon to XBM format: |
|
354 |
|
355 XBMReader save:(Image fromFile:'bitmaps/hello_world.icon') onFile:'test.xbm' |
|
356 " |
|
357 |
|
358 "Modified: 27.2.1997 / 12:46:49 / cg" |
|
359 ! |
|
360 |
|
361 save:image onStream:aStream |
319 save:image onStream:aStream |
362 "save image as XBM cdata on aStream. |
320 "save image as XBM cdata on aStream. |
363 Only depth1 b&w images can be represented in this format." |
321 Only depth1 b&w images can be represented in this format." |
364 |
322 |
365 |reverseBits bits byte |
323 |reverseBits bits byte |