eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ImageReader':

Home

everywhere
www.exept.de
for:
[back]

Class: ImageReader


Inheritance:

   Object
   |
   +--ImageReader
      |
      +--AVIReader
      |
      +--BlitImageReader
      |
      +--FLIReader
      |
      +--GIFReader
      |
      +--JPEGReader
      |
      +--PBMReader
      |
      +--PCXReader
      |
      +--PICTReader
      |
      +--PNGReader
      |
      +--TIFFReader
      |
      +--WindowsIconReader
      |
      +--XBMReader
      |
      +--XPMReader

Package:
stx:libview
Category:
Graphics-Images-Readers
Version:
rev: 1.97 date: 2009/11/16 22:59:26
user: mb
file: ImageReader.st directory: libview
module: stx stc-classLibrary: libview
Author:
Claus Gittinger

Description:


Abstract class to provide common functions for image-readers
(i.e. TIFFReader, GIFReader etc.)

ImageReaders are created temporary to read an image from a stream.
Normally, they are not directly used - instead, the image class is
asked to read some file, and return an instance for it:
    Image fromFile:<someFileName>
The Image class will guess the images format and forward the task to
some concrete ImageReaderClass.
If that class finds, that the files format is incorrect, other readers
are tried until some finds the files format acceptable.

Image readers read the stream and collect all relevant information internally.
Once done with reading, the actual image object is created and
data filled in from the imageReaders collected info.

See the implementation of #fromStream: in concrete subclasses.
The public interfaces are:
     <ConcreteReaderClass> fromFile:aFilename
or:
     <ConcreteReaderClass> fromStream:aStream

If you add a new reader, dont forget to add the method #isValidImageFile:
which should return true, if this reader supports reading a given file.
If your new reader class supports writing files, dont forget to add
#canRepresent:anImage and return true from this method.


Related information:

    Image
    Icon
    Form

Class protocol:

cleanup
o  lowSpaceCleanup
cleanup things we do not need

constants
o  reverseBits
return a table filled with bit reverse information.
To convert from msbit-first to lsbit-first bytes, use
the value as index into the table, retrieving the reverse
value. Since indexing must start at 1, use (value + 1) as
index.

decompression support
o  decodeDelta: step in: data width: width height: height
perform NeXT special predictor delta decoding inplace in data.
Calls primitive c function for speed

o  decompressCCITT3From: srcBytes into: dstBytes startingAt: offset count: count
decompress CCITT Group 3 compressed image data.
count bytes from srcBytes are decompressed into dstBytes.
Calls primitive c function for speed

o  decompressGIFFrom: srcBytes count: count into: dstBytes startingAt: offset codeLen: codeLen
decompress GIF compressed image data.
count bytes from srcBytes are decompressed into dstBytes.
Calls primitive c function for speed

o  decompressLZWFrom: srcBytes count: count into: dstBytes startingAt: offset
decompress LZW (tiff) compressed image data.
count bytes from srcBytes are decompressed into dstBytes.
Calls primitive c function for speed

o  decompressRLEFrom: srcBytes at: srcStartIndex into: dstBytes at: dstStartIndex increment: dstIncrement
common helper to expand RLE encoded data

o  swap: nBytes bytesFromRGB_to_BGR_in: data
swap bytes from RGB into BGR order.
The argument is a pixel data buffer (byteArray)

o  swap: nBytes bytesFromRGB_to_BGR_in: data startingAt: startIndex
swap bytes from RGB into BGR order.
The argument is a pixel data buffer (byteArray)

i/o support
o  streamReadingFile: aFilename
return a stream to read aFilename.
If the filename ends with '.Z' or '.gz', return a stream
to a pipe for the uncompressor. Otherwise, return a stream to read
the file directly.

image reading
o  fromFile: aFileName
read an image (in my format) from aFileName.
Return the image or nil on error.

o  fromStream: aStream
read an image (in my format) from aStream.
Return the image or nil (if unrecognized format or error).
The stream remains open.

o  imagesFromFile: aFileName
read all images (in my format) from aFileName.
Return a collection of images or nil on error.
Not all reader may support multiple images.

o  imagesFromStream: aStream
read all images (in my format) from aStream.
Return a collection of images or nil (if unrecognized format or error).
The stream remains open.
Not all reader may support multiple images.

o  readFile: aFilename
create a reader and let it read an image (in my format) from aFilename.
Return the reader.

o  readStream: aStream
create a reader and let it read a stream (in my format).
Return the reader. The stream remains open.

image support
o  buildMaskFromColor: maskPixelValue for: pixels width: width height: height
helper for image formats, where an individual pixel value
has been defined as a mask-pixel (i.e. GIF).
Creates a maskImage, with zeros at positions where the image
has the given pixelValue; all other mask pixels are set to 1.

image writing
o  save: anImage onFile: aFileName
save the image in my format on aFileName

o  save: anImage onStream: aStream
save the image in my format on a Stream

instance creation
o  new

testing
o  canRepresent: anImage
return true, if anImage can be represented in my file format.
must be redefined in concrete subclasses which support saving.

o  isValidImageFile: aFileName
return true, if aFileName contains an image this
reader understands - must be redefined in concrete subclasses
which support reading.


Instance protocol:

accessing
o  bitsPerPixel
return the number of bits per pixel

o  bitsPerRow
return the number of bits in one scanline of the image

o  bitsPerSample
return the number of bits per sample

o  bytesPerRow
return the number of bytes in one scanline of the image

o  colorMap
return the colormap

o  data
return the raw image data

o  hasMultipleImages

o  height
return the height of the image

o  image
return the image as represented by myself;
If my file contained multiple images, return the first one.

o  imageFrames
return a collection of all imageFrames as represented by myself.
ImageFrames are wrappers for individual images, which hold
additional information (such as image delay time).
Nil is return for single image formats/files.

o  images
return a collection of all images as represented by myself.
For compatibility with single-image formats, return a collection
containing my single image here if the reader does not support
multiple images.
Readers for formats with multiple images should leave the images
in the imageSequence instVar as a side effect of reading.

o  makeImage
return the image as represented by the values found in my
instvars; these have been typically set as a side effect of
the fromStream:-method, which reads images.

o  mask
return the image mask (or nil)

o  numberOfImages
return the number of images as read.
By default (here), I hold a single image;
however, some fileFormats allow for multiple images

o  photometric
return the photometric interpretation of the image data

o  samplesPerPixel
return the number of samples per pixel

o  width
return the width of the image

accessing-private
o  byteOrder: aSymbol
set the byte order - either #lsb or #msb

o  inStream

o  inStream: aStream

error reporting
o  fileFormatError: aMessage
report a format error - no image could be read

i/o support
o  readLong
return the next 4-byte long, honoring the byte-order

o  readShort
return the next 2-byte short, honoring the byte-order

o  readShortLong
return the next 2-byte short, honoring the byte-order.
There are actually 4 bytes read, but only 2 looked at.

o  readUnsignedLong
return the next 4-byte long, honoring the byte-order

o  writeLong: anInteger
write a 4-byte long, honoring the byte-order.

o  writeShort: anInteger
write a 2-byte short, honoring the byte-order.

image reading
o  fromStream: aStream
read an image in my format from aStream.
Leave image description in instance variables.

o  readImage
read an image in my format from my inStream.
Leave image description in instance variables.

** This method raises an error - it must be redefined in concrete classes **

image reading support
o  buildMaskFromColor: maskPixelValue
helper for image formats, where an individual pixel value
has been defined as a mask-pixel (i.e. GIF).
Creates a maskImage, with zeros at positions where the image
has the given pixelValue; all other mask pixels are set to 1.

image writing
o  save: image onFile: aFileName
save image in my format on aFile

o  save: image onStream: aStream
save image in my format on a Stream

initialization
o  initialize
Created: 18.2.1997 / 17:08:31 / cg

progress reporting
o  dimensionCallBack: aBlock
set the block, which is evaluated during the readProcess, as soon as
the images dimension is known. This is useful for background image reading,
if the size is need to be known (for example: for formatting purposes).
Obsoleted by dimensionHolder.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  dimensionHolder: aValueHolderOrBlock
set the valueHolder or block, which is evaluated during the readProcess,
as soon as the images dimension is known.
Useful for background image reading, if the size is need to be known (for example: for formatting purposes).

o  progressHolder: aValueHolderOrBlock
set the valueHolder or block, which is evaluated during the readProcess,
and set with progress information (0..100 percent).
Useful for user feedback

o  reportDimension

o  reportProgress: fraction
can be used by a GUI application to indicate loading progress (0..1)



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 19:34:59 GMT