eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MacOSXIconReader':

Home

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

Class: MacOSXIconReader


Inheritance:

   Object
   |
   +--ImageReader
      |
      +--MacOSXIconReader

Package:
stx:libview2
Category:
Graphics-Images-Readers
Version:
rev: 1.32 date: 2023/05/26 06:41:16
user: stefan
file: MacOSXIconReader.st directory: libview2
module: stx stc-classLibrary: libview2

Description:


Reader/writer for mac osx icon files.

These files are actually bundles of a sequence of icons (in possibly different resolutions,
colors and sizes).
When such a file is read, I return the first image as usual, 
and all images as an imagesequence.

Only a subset of the supported image formats are supported by the writer
(i.e. JPEG and PNG based image encodings only). 
This means, that only 10.8-and later icon files are really generated.

[caveat:]
    only a subset of the possibly formats are supported.

[notice:]
    when reading an ICNS file with multiple icons in it,
    the first image is returned as such, holding on the other images in its
    imageFrames instvar.
    Thus, the imageEditor will usually present the first of the images,
    and offer a next-in-sequence button to step through them.
    To get a collection of all images, collect the images from the sequence, as in:
        someIcoImage imageFrames collect:#image

[supported formats:]

support   format   length                pixels  OS-version  description
-----------------------------------------------------------------------------   
r           ICON    128                     32      1.0     32×32 1-bit mono icon
r           ICN#    256                     32      6.0     32×32 1-bit mono icon with 1-bit mask
            icm#    48                      16      6.0     16×12 1 bit mono icon with 1-bit mask
            icm4    96                      16      7.0     16×12 4 bit icon
            icm8    192                     16      7.0     16×12 8 bit icon
r           ics#    64 (32 img + 32 mask)   16      6.0     16×16 1-bit mask
r           ics4    128                     16      7.0     16×16 4-bit icon
r           ics8    256                     16      7.0     16x16 8 bit icon
            is32    varies (768)            16      8.5     16×16 24-bit icon
r           s8mk    256                     16      8.5     16x16 8-bit mask
r           icl4    512                     32      7.0     32×32 4-bit icon
r           icl8    1,024                   32      7.0     32×32 8-bit icon
r           il32    varies (3,072)          32      8.5     32x32 24-bit icon
r           l8mk    1,024                   32      8.5     32×32 8-bit mask
r           ich#    288                     48      8.5     48×48 1-bit mask
r           ich4    1,152                   48      8.5     48×48 4-bit icon
r           ich8    2,304                   48      8.5     48×48 8-bit icon
r           ih32    varies (6,912)          48      8.5     48×48 24-bit icon
r           h8mk    2,304                   48      8.5     48×48 8-bit mask
r           it32    varies (49,152)        128     10.0    128×128 24-bit icon
r           t8mk    16,384                 128     10.0    128×128 8-bit mask
r           icp4    varies                  16     10.7    16x16 icon in JPEG 2000 or PNG format
r           icp5    varies                  32     10.7    32x32 icon in JPEG 2000 or PNG format
            icp6    varies                  64     10.7    64x64 icon in JPEG 2000 or PNG format
r           ic07    varies                 128     10.7    128x128 icon in JPEG 2000 or PNG format
r           ic08    varies                 256     10.5    256×256 icon in JPEG 2000 or PNG format
r           ic09    varies                 512     10.5    512×512 icon in JPEG 2000 or PNG format
r           ic10    varies                1024     10.7    1024×1024 in 10.7 (or 512x512@2x 'retina' in 10.8) icon in JPEG 2000 or PNG format
            ic11    varies                  32     10.8    16x16@2x 'retina' icon in JPEG 2000 or PNG format
            ic12    varies                  64     10.8    32x32@2x 'retina' icon in JPEG 2000 or PNG format
            ic13    varies                 256     10.8    128x128@2x 'retina' icon in JPEG 2000 or PNG format
            ic14    varies                 512     10.8    256x256@2x 'retina' icon in JPEG 2000 or PNG format

 Other types (ignored):
           'TOC '   varies          'Table of Contents' 
                                    a list of all image types in the file, 
                                    and their sizes (added in Mac OS X 10.7)

            'icnV'  4               4-byte big endian float 
                                    - equal to the bundle version number of Icon Composer.app that created to icon

copyright

COPYRIGHT (c) 2013 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 `.icns' extension.

testing
o  canRepresent: anImage
return true, if anImage can be represented in my file format.
Assuming that we store in PNG format, delegate that decision.

o  hasValidImageHeader: someHeaderBytes
return true, if someHeaderBytes
(which does not need to be the whole data, but large enough
to detect the header) contains a valid TIFF image header

o  isValidImageStream: inStream
return true, if inStream contains an apple osx icon file


Instance protocol:

image reading
o  fromStream: aStream
read a stream containing an icon image (or a collection of images).
Leave image description in instance variables.

o  readSingleIcon: iconType from: iconBytes
read a single image from the inputStream.

image writing
o  save: anImage onStream: aStream
save an icon to aStream.

Usage example(s):

     self 
        save:(Image fromScreen:(0@0 corner:16@16))
        onFile:'test.icns'

o  saveAll: aCollectionOfImages onStream: aStream
save a number of images to aStream.

Usage example(s):

     self 
        save:(Image fromScreen:(0@0 corner:16@16))
        onFile:'test.icns'.
        
     'test.icns' asFilename exists.

     Image fromFile:'test.icns'

     ImageSequence
     MacOSXIconReader
         saveAll:{
                    (Image fromScreen:(0@0 corner:16@16)) .
                    (Image fromScreen:(0@0 corner:32@32)) .
                    (Image fromScreen:(0@0 corner:64@64)) .
                    (Image fromScreen:(0@0 corner:128@128)) .
                 }
         onFile:'test.icns'   

private
o  colormap4

o  colormap8

o  makeImage
image is already made

private reading
o  common_read_paletteImage_from: bytes size: size width: w height: h depth: d
read an icl8/icl4/ics4/ics8 icon

o  readPNGOrJPEGFrom: bytes expectedSize: expectedSizeOrNil
read a PNG or JPEG image.
Helper for ipc4, ipc5, ipc6, ic07, ic09, ic10 formats

o  readPackBitsImageFrom: compressedData offset: offset width: w height: h depth: depth
rgb channels separate

o  read_ICN__from: bytes
read an ICN# format icon.
ICN# is 32x32 bit mono with 1-bit mask

o  read_ICON_from: bytes
read an ICON format icon.
128 bytes, 32x32x1 monochrome

o  read_TOC__from: bytes
read (actually: skip) a table of contents.

o  read_h8mk_from: bytes
read an h8mk packbits format mask icon

o  read_ic07_from: bytes
read an ic07 (PNG or JPEG, 128x128) format icon

o  read_ic08_from: bytes
read an ic08 (PNG or JPEG, 256x256) format icon

o  read_ic09_from: bytes
read an ic09 (PNG or JPEG, 512x512) format icon

o  read_ic10_from: bytes
read an ic10 (PNG or JPEG, 1024x1024) format icon

o  read_ic11_from: bytes
read an ic11 (PNG or JPEG, 32x32) format icon

o  read_ic12_from: bytes
read an ic12 (PNG or JPEG, 64) format icon

o  read_ic13_from: bytes
read an ic12 (PNG or JPEG, 256x256) format icon

o  read_ic14_from: bytes
read an ic12 (PNG or JPEG, 512x512) format icon

o  read_ich4_from: bytes
read an ich4 format icon;
1152 bytes; 48x48x4bit

o  read_ich8_from: bytes
read an ich8 format icon;
2304 bytes; 48x48x8bit

o  read_ich__from: bytes
read an ich# format icon.
ich# is 288+288 bytes, 48x48x1 monochrome + mask

o  read_icl4_from: bytes
read an icl4 format icon;
512 bytes; 32x32x4bit

o  read_icl8_from: bytes
read an icl8 format icon;
1024 bytes; 32x32x8bit

o  read_icm4_from: bytes
read (actually: skip) an icm4 record.

o  read_icm8_from: bytes
read (actually: skip) an icm8 record.

o  read_icm__from: bytes
read (actually: skip) an icm# record.

o  read_icnV_from: bytes
read (actually: skip) an icnV record.

o  read_icp4_from: bytes
read an ipc4 (PNG or JPEG, 16x16) format icon

o  read_icp5_from: bytes
read an ipc5 (PNG or JPEG, 32x32) format icon

o  read_icp6_from: bytes
read an ipc6 (PNG or JPEG, 64x64) format icon

o  read_ics4_from: bytes
read an ics4 format icon.
128 bytes, 16x16x4bit

o  read_ics8_from: bytes
read an ics8 format icon.
256 bytes, 16x16x8bit

o  read_ics__from: bytes
read an ics# format icon.
ics# is 64 bytes, 16x16x1 monochrome + mask

o  read_icsb_from: bytes
read (actually: skip) an icsb record.

o  read_icsd_from: bytes
read (actually: skip) an icsd record.

o  read_ih32_from: bytes
read an ih32 packbits format 48x48x24 icon

o  read_il32_from: bytes
read an il32 packbits format 32x32x24 icon

o  read_ipc4_from: bytes
read an ipc4 (PNG or JPEG, 16x16) format icon

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

o  read_ipc5_from: bytes
read an ipc5 (PNG or JPEG, 32x32) format icon

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

o  read_ipc6_from: bytes
read an ipc6 (PNG or JPEG, 64x64) format icon

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

o  read_is32_from: bytes
read an is32 packbits format 16x16x24 icon

o  read_it32_from: bytes
read an it32 packbits format 128x128x24 icon

o  read_l8mk_from: bytes
read an l8mk packbits format mask icon

o  read_name_from: bytes
read (actually: skip) a name entry.

o  read_s8mk_from: bytes
read an s8mk packbits format mask icon

o  read_t8mk_from: bytes
read an t8mk 128x128x8 mask icon



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:35:17 GMT