eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PNGReader':

Home

everywhere
www.exept.de
for:
[back]

Class: PNGReader


Inheritance:

   Object
   |
   +--ImageReader
      |
      +--PNGReader

Package:
stx:libview2
Category:
Graphics-Images-Readers
Version:
rev: 1.51 date: 2017/01/18 16:06:24
user: cg
file: PNGReader.st directory: libview2
module: stx stc-classLibrary: libview2
Author:
Claus Gittinger

Description:


This class will provide methods for loading and saving PNG pictures.
It is currenty unfinished (some interlaced image formats are unsupported, for example: grayscale+alpha)
In the meantime, use a pngtoXXX converter for interlaced images, and read XXX.

[caveats:]
    writer ignores any mask (for now).
    writer only generates unfiltered non-interlaced data
    


Related information:

    Image
    Form
    Icon
    BlitImageReader
    FaceReader
    GIFReader
    JPEGReader
    PBMReader
    PCXReader
    ST80FormReader
    SunRasterReader
    TargaReader
    TIFFReader
    WindowsIconReader
    XBMReader
    XPMReader
    XWDReader

Class protocol:

initialization
o  initialize
install myself in the Image classes fileFormat table for the `.png' extension.

queries
o  canRepresent: anImage
return true, if anImage can be represented in my file format.
Any image is supported.

testing
o  isValidImageFile: aFileName
return true, if aFileName contains a PNG image
usage example(s):


     self isValidImageFile:'/home/cg/AudioExplorer_51_files/use_small.png'
     self isValidImageFile:'C:\Users\cg\Desktop\croquet\cobalt-base-current-build-20090210\cobalt-base-current-build-20090210\content\models\textures\checkerboard.png'
     self isValidImageFile:'C:\Dokumente und Einstellungen\cg\Desktop\misc\PNGs\Delete.png'


Instance protocol:

private-chunks
o  doPass: pass
Certain interlace passes are skipped with certain small image dimensions

o  processBKGDChunkLen: len

o  processCHRMChunkLen: len
cHRM Primary chromaticities chunk - currently unhandled

o  processChunk: type len: len
---since the compressed data can span multiple
chunks, stitch them all together first. later,
if memory is an issue, we need to figure out how
to do this on the fly---

o  processGAMAChunkLen: len

o  processGlobalIDATChunk

o  processICCPChunkLen: len
ignored

o  processIDATChunkLen: len

o  processIHDRChunkLen: len
ignored

o  processITXTChunkLen: len
international (i.e.utf8) textual data.

o  processInterlacedDATA: len

o  processInterlacedGlobalDATA
adam7 interlace method

o  processNonInterlacedDATA: len

o  processNonInterlacedGlobalDATA
data n

o  processPHYSChunkLen: len
physical pixel chunk - currently unhandled

o  processPLTEChunkLen: len
read a color palette

o  processSBITChunkLen: len

o  processTEXTChunkLen: len
textual data in iso8859 coding.

o  processTIMEChunkLen: len

o  processTRNSChunkLen: len

o  processZTXTChunkLen: len
compressed text

private-filtering
o  filterAverage: count
Use the average of the pixel to the left and the pixel above as a predictor

o  filterHorizontal: count
use the pixel to the left as a predictor

o  filterNone: count
no filter - scanline is as is

o  filterPaeth: count
Select one of (the pixel to the left, the pixel above and the pixel to above left) to
predict the value of this pixel

o  filterScanline: filterType count: count

o  filterVertical: count
Use the pixel above as a predictor

o  paethPredictLeft: l above: a aboveLeft: al
Predicts the value of a pixel based on nearby pixels, based on Paeth (GG II, 1991)

private-pixel copy
o  copyPixels: y at: startX by: incX
Handle interlaced pixels of supported colorTypes

o  copyPixelsGray: y at: startX by: incX
Handle interlaced pixels of supported colorTypes.
Untested code - please verify

o  copyPixelsIndexed: y at: startX by: incX

o  copyPixelsRGB: y at: startX by: incX
Handle interlaced pixels of supported colorTypes.
Untested code - please verify

o  copyPixelsRGBA: y at: startX by: incX
Handle interlaced pixels of supported colorTypes.
Untested code - please verify

private-reading
o  getChunk
ignored - for now

o  getIHDRChunk
will be changed by setColorType.

o  handleText: text keyword: keyword
things like exif data etc.

o  setColorType: colorType

reading
o  fromStream: aStream
read a stream containing a PNG image.
Leave image description in instance variables.

writing to file
o  pngHeader

o  save: image onStream: aStream
save image in PNG-file-format onto aStream

o  writeChunk: chunkTypeChars size: len with: aBlock

o  writeEndChunk

o  writeFileHeader

o  writeIHDRChunk
+alpha

o  writeImageDataChunk
no filter

o  writePaletteChunk


Examples:


PNGReader fromFile:'/home/cg/AudioExplorer_51_files/use_small.png' PNGReader fromFile:'\\Exeptn\tmp\images\expeccoScreenshot4020_5526507.png' PNGReader fromFile:'C:\Users\cg\Desktop\croquet\cobalt-base-current-build-20090210\cobalt-base-current-build-20090210\content\models\textures\checkerboard.png' PNGReader fromFile:'C:\Dokumente und Einstellungen\cg\Desktop\misc\PNGs\Delete.png' PNGReader fromFile:'\\exeptn\unsaved\pd_stuff\PNGs\Delete.png' PNGReader fromFile:'\\exeptn\unsaved\pd_stuff\PNGs\Down.png' |img img2 outStream png| img := ToolbarIconLibrary error32x32Icon. outStream := WriteStream on:(ByteArray new:100). PNGReader save:img onStream:outStream. png := outStream contents. img2 := PNGReader fromStream:(png readStream). self assert:(img bits = img2 bits). img inspect. img2 inspect.

ST/X 7.1.0.0; WebServer 1.653 at exept.de:8081; Sun, 21 Jan 2018 14:16:00 GMT