eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'XBMReader':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: XBMReader


Inheritance:

   Object
   |
   +--ImageReader
      |
      +--XBMReader

Package:
stx:libview2
Category:
Graphics-Images-Readers
Version:
rev: 1.67 date: 2023/10/12 16:16:38
user: stefan
file: XBMReader.st directory: libview2
module: stx stc-classLibrary: libview2

Description:


this class provides methods for loading and saving x-bitmap-file images.
These images can (for example) be created using the bitmap editor supplied
with X. 
Only monochrome images can be represented in this format.
Both reading and writing of images is supported.

copyright

COPYRIGHT (c) 1992 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

class initialization
o  initialize
tell Image-class, that a new fileReader is present
for the '.xbm' extension.

testing
o  canRepresent: anImage
return true, if anImage can be represented in my file format

o  isValidImageStream: inStream
return true, if inStream possibly contains a XBM image.
The stream is left open and position undefined afterwards


Instance protocol:

private-reading
o  extractValueFor: keyword fromLine: lineString

reading
o  fromStream: aStream
read an image in xbm format from aStream.
Leave image description in instance variables.
(i.e. to get the image, ask with image).

writing
o  save: image onStream: aStream
save image as XBM cdata on aStream.
Only depth1 b&w images can be represented in this format.

Usage example(s):

     |file original restored|

     original := Image fromFile:'../../goodies/bitmaps/xbmBitmaps/TicTacToe.xbm'.
     file := String streamContents:[:stream |
        XBMReader save:original onStream:stream
     ].
     restored := XBMReader fromStream:(file readStream).
     self assert:(restored = original)


Examples:


Reading from a file:
  |image|

  image := Image fromFile:('../../goodies/bitmaps/xbmBitmaps/TicTacToe.xbm').
  image inspect
Saving to a file:
  |image|

  image := Image fromScreen:(0@0 corner:30@30).
  image := image asThresholdMonochromeImage.
  XBMReader save:image onFile:'/tmp/test.xbm'.
  '/tmp/test.xbm' asFilename contents asString inspect.
  (Image fromFile:('/tmp/test.xbm')) inspect.
Or directly into a stream:
  |image stream|

  image := Image fromScreen:(0@0 corner:30@30).
  image := image asThresholdMonochromeImage.
  stream := WriteStream on:(String new).
  XPMReader save:image onStream:stream.
  stream contents inspect.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 05:51:37 GMT