|
Class: MacOSXIconReader
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
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
copyrightCOPYRIGHT (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 initialization
-
initialize
-
install myself in the Image classes fileFormat table
for the `.icns' extension.
testing
-
canRepresent: anImage
-
return true, if anImage can be represented in my file format.
Assuming that we store in PNG format, delegate that decision.
-
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
-
isValidImageStream: inStream
-
return true, if inStream contains an apple osx icon file
image reading
-
fromStream: aStream
-
read a stream containing an icon image (or a collection of images).
Leave image description in instance variables.
-
readSingleIcon: iconType from: iconBytes
-
read a single image from the inputStream.
image writing
-
save: anImage onStream: aStream
-
save an icon to aStream.
Usage example(s):
self
save:(Image fromScreen:(0@0 corner:16@16))
onFile:'test.icns'
|
-
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
-
colormap4
-
-
colormap8
-
-
makeImage
-
image is already made
private reading
-
common_read_paletteImage_from: bytes size: size width: w height: h depth: d
-
read an icl8/icl4/ics4/ics8 icon
-
readPNGOrJPEGFrom: bytes expectedSize: expectedSizeOrNil
-
read a PNG or JPEG image.
Helper for ipc4, ipc5, ipc6, ic07, ic09, ic10 formats
-
readPackBitsImageFrom: compressedData offset: offset width: w height: h depth: depth
-
rgb channels separate
-
read_ICN__from: bytes
-
read an ICN# format icon.
ICN# is 32x32 bit mono with 1-bit mask
-
read_ICON_from: bytes
-
read an ICON format icon.
128 bytes, 32x32x1 monochrome
-
read_TOC__from: bytes
-
read (actually: skip) a table of contents.
-
read_h8mk_from: bytes
-
read an h8mk packbits format mask icon
-
read_ic07_from: bytes
-
read an ic07 (PNG or JPEG, 128x128) format icon
-
read_ic08_from: bytes
-
read an ic08 (PNG or JPEG, 256x256) format icon
-
read_ic09_from: bytes
-
read an ic09 (PNG or JPEG, 512x512) format icon
-
read_ic10_from: bytes
-
read an ic10 (PNG or JPEG, 1024x1024) format icon
-
read_ic11_from: bytes
-
read an ic11 (PNG or JPEG, 32x32) format icon
-
read_ic12_from: bytes
-
read an ic12 (PNG or JPEG, 64) format icon
-
read_ic13_from: bytes
-
read an ic12 (PNG or JPEG, 256x256) format icon
-
read_ic14_from: bytes
-
read an ic12 (PNG or JPEG, 512x512) format icon
-
read_ich4_from: bytes
-
read an ich4 format icon;
1152 bytes; 48x48x4bit
-
read_ich8_from: bytes
-
read an ich8 format icon;
2304 bytes; 48x48x8bit
-
read_ich__from: bytes
-
read an ich# format icon.
ich# is 288+288 bytes, 48x48x1 monochrome + mask
-
read_icl4_from: bytes
-
read an icl4 format icon;
512 bytes; 32x32x4bit
-
read_icl8_from: bytes
-
read an icl8 format icon;
1024 bytes; 32x32x8bit
-
read_icm4_from: bytes
-
read (actually: skip) an icm4 record.
-
read_icm8_from: bytes
-
read (actually: skip) an icm8 record.
-
read_icm__from: bytes
-
read (actually: skip) an icm# record.
-
read_icnV_from: bytes
-
read (actually: skip) an icnV record.
-
read_icp4_from: bytes
-
read an ipc4 (PNG or JPEG, 16x16) format icon
-
read_icp5_from: bytes
-
read an ipc5 (PNG or JPEG, 32x32) format icon
-
read_icp6_from: bytes
-
read an ipc6 (PNG or JPEG, 64x64) format icon
-
read_ics4_from: bytes
-
read an ics4 format icon.
128 bytes, 16x16x4bit
-
read_ics8_from: bytes
-
read an ics8 format icon.
256 bytes, 16x16x8bit
-
read_ics__from: bytes
-
read an ics# format icon.
ics# is 64 bytes, 16x16x1 monochrome + mask
-
read_icsb_from: bytes
-
read (actually: skip) an icsb record.
-
read_icsd_from: bytes
-
read (actually: skip) an icsd record.
-
read_ih32_from: bytes
-
read an ih32 packbits format 48x48x24 icon
-
read_il32_from: bytes
-
read an il32 packbits format 32x32x24 icon
-
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) **
-
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) **
-
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) **
-
read_is32_from: bytes
-
read an is32 packbits format 16x16x24 icon
-
read_it32_from: bytes
-
read an it32 packbits format 128x128x24 icon
-
read_l8mk_from: bytes
-
read an l8mk packbits format mask icon
-
read_name_from: bytes
-
read (actually: skip) a name entry.
-
read_s8mk_from: bytes
-
read an s8mk packbits format mask icon
-
read_t8mk_from: bytes
-
read an t8mk 128x128x8 mask icon
|