eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PBMReader':

Home

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

Class: PBMReader


Inheritance:

   Object
   |
   +--ImageReader
      |
      +--PBMReader

Package:
stx:libview2
Category:
Graphics-Images-Readers
Version:
rev: 1.46 date: 2023/05/04 15:02:41
user: cg
file: PBMReader.st directory: libview2
module: stx stc-classLibrary: libview2

Description:


this class provides methods for loading and saving Portable BitMap-file 
images (Jef Poskanzers portable bitmap package).

Reading is supported for 1bit (pbm), greyscale (pgm) and 24bit (ppm) formats.
(i.e. P1, P3, P4, P5, P6 and P7 formats)

Writing is (currently) only supported for the binary formats;
i.e. 1-bit images as (pbm P4), 8-bit gray as (pgm P5) and 24-bit images as (pnm P6).

Q: should we broil this one to perfection and base all others on
   pipe-readers to the various pbmplus converters ?

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
install myself in the Image classes fileFormat table
for the `.pbm', '.pgm' and '.pnm' extensions.

testing
o  canRepresent: anImage
return true, if anImage can be represented in my file format.
Currently, only 1bit B&W, 8bit-grey and 24bit RGB images are supported.

o  isValidImageStream: inStream
return true, if inStream contains a PBM image (which I can read)


Instance protocol:

private-reading
o  readMaxVal

o  readWidthAndHeight

o  readWidthAndHeightAndMaxVal

o  skipPBMJunk
this method removes any superfluous characters from the input stream.

private-writing
o  writeCommonHeader: format on: aStream
common header for P4, P5 and P5 formats

reading
o  fromStream: aStream
read a Portable bitmap file format as of Jeff Poskanzers Portable Bitmap Package.
supported are PPM, PBM, PGM and PNM files.

o  readDepth1AsciiPBMStream
import portable bitmap ascii (PBM, P1 format); P1 is already read

o  readDepth1PBMStream
import portable bitmap (PBM, P4 format); P4 is already read

o  readDepth24AsciiPBMStream
import ascii portable pixmap (PBM, P3 format); P3 is already read

o  readDepth24PPMStream
import portable pixmap (PPM, P6 format); P6 is already read

o  readDepth8PGMStream
import portable gray map (PGM, P5 format); P5 is already read

o  readDepth8PPMStream
import portable pixmap (PPM, P7 format); P7 is already read

writing
o  save: image onStream: aStream
save image as PBM/PGM/PNM file on aFileName

o  writePBMFileOn: aStream
Saves the receivers image on the file fileName in Portable Bitmap format.

o  writePGMFileOn: aStream
Saves the receiver's image on the file fileName in Portable Greymap format.

o  writePNMFileOn: aStream
Saves the receivers image on the file fileName in Portable Anymap format.


Examples:


(PBMReader fromFile:'../../support/libjpeg-9/testimg.ppm')
    inspect


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 11:34:50 GMT