Supported Image File Formats/en: Unterschied zwischen den Versionen
KKeine Bearbeitungszusammenfassung |
Cg (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
The underlying runtime framework supports the most common bitmap/image formats: |
|||
GIF |
|||
JPEG |
|||
PNG |
|||
TIFF |
|||
BMP |
|||
XPM |
|||
== Image Reading == |
|||
Elementary code can access readers as subclasses of ImageReader (a slightly missleading name - most of them can write image files as well). To read an an image, use one of: |
|||
<readerClass> fromFile: 'someFilename' |
|||
<readerClass> fromStream: aReadStream |
|||
<readerClass> fromBase64Stream: aReadStream |
|||
<readerClass> fromBytes: aByteCollection |
|||
<readerClass> fromURL: 'aURL' |
|||
If one of those messages is sent to the common superclass "ImageReader", it will try to determine the format (from the file extension and/or the first few header bytes in the data. |
|||
IF it is sent to a concrete reader class (GIFReader, JPEGReader, TIFFReader, PNReader etc..) the format should match the readers expectations. You get a list of existing readers via "ImageReader allSubclasses" or by opening a System Browser ("''Extras''" - "''Tools''" - "''Class Browser''") |
|||
== Image Writing == |
|||
An image can be saved in a file or sent to a stream in one of the supported formats with: |
|||
<readerClass> save: anImage onFile: 'someFilename' |
|||
<readerClass> save: anImage onStream: aStream |
|||
== Capturing Images == |
|||
Images can be captured from the screen with: |
|||
Image fromScreen |
|||
Image fromScreen: aRectangle |
|||
== Manipulating Images == |
|||
A few often used image manipulation functions are already built in. More siphisticated functions can be called via Python or C actions, which call into an imported image maniulation library. |
|||
Things you can do out-of-the-box are: |
|||
anImage magnifiedBy:scaleFactor |
|||
anImage magnifiedTo:anExtent smooth:aBoolean |
|||
anImage magnifiedPreservingRatioTo:anExtent smooth:aBoolean |
|||
anImage rotatedBy: angleInDegrees |
|||
anImage subImageIn: aRetangle |
|||
anImage flipVertical / flipHorizontal |
|||
=== Examples === |
|||
==== Take a Screenshot, extracting a Rectangle, scaling it and saving on File ==== |
|||
|img subImg magImg| |
|||
img := Image fromScreen. |
|||
subImg := img subImageIn:( 0@0 extent:400@400). |
|||
magImg := subImg magnifiedTo:200@200 smooth:true. |
|||
PNGReader save:magImg onFile:'testFile.png'. |
|||
"/ the following opens a viewer on the file |
|||
OperatingSystem openApplicationForDocument:'testFile.png' operation:#open. |
|||
== Limitations == |
|||
Although expecco supports a wide range of bitmap image formats, some rarely used formats are not supported, or only supported with limitations. |
Although expecco supports a wide range of bitmap image formats, some rarely used formats are not supported, or only supported with limitations. |
||
Version vom 23. Juni 2022, 12:52 Uhr
The underlying runtime framework supports the most common bitmap/image formats:
GIF JPEG PNG TIFF BMP XPM
Image Reading
Elementary code can access readers as subclasses of ImageReader (a slightly missleading name - most of them can write image files as well). To read an an image, use one of:
<readerClass> fromFile: 'someFilename' <readerClass> fromStream: aReadStream <readerClass> fromBase64Stream: aReadStream <readerClass> fromBytes: aByteCollection <readerClass> fromURL: 'aURL'
If one of those messages is sent to the common superclass "ImageReader", it will try to determine the format (from the file extension and/or the first few header bytes in the data.
IF it is sent to a concrete reader class (GIFReader, JPEGReader, TIFFReader, PNReader etc..) the format should match the readers expectations. You get a list of existing readers via "ImageReader allSubclasses" or by opening a System Browser ("Extras" - "Tools" - "Class Browser")
Image Writing
An image can be saved in a file or sent to a stream in one of the supported formats with:
<readerClass> save: anImage onFile: 'someFilename' <readerClass> save: anImage onStream: aStream
Capturing Images
Images can be captured from the screen with:
Image fromScreen Image fromScreen: aRectangle
Manipulating Images
A few often used image manipulation functions are already built in. More siphisticated functions can be called via Python or C actions, which call into an imported image maniulation library.
Things you can do out-of-the-box are:
anImage magnifiedBy:scaleFactor anImage magnifiedTo:anExtent smooth:aBoolean anImage magnifiedPreservingRatioTo:anExtent smooth:aBoolean anImage rotatedBy: angleInDegrees anImage subImageIn: aRetangle anImage flipVertical / flipHorizontal
Examples
Take a Screenshot, extracting a Rectangle, scaling it and saving on File
|img subImg magImg|
img := Image fromScreen. subImg := img subImageIn:( 0@0 extent:400@400). magImg := subImg magnifiedTo:200@200 smooth:true. PNGReader save:magImg onFile:'testFile.png'. "/ the following opens a viewer on the file OperatingSystem openApplicationForDocument:'testFile.png' operation:#open.
Limitations
Although expecco supports a wide range of bitmap image formats, some rarely used formats are not supported, or only supported with limitations.
GIF
Reading and writing of 8 bit/pixel palette images is supported. Other images should be converted to 8bpp before writing. Tiled images with multiple palettes are not supported.
JPEG
Reading and writing of 24bit/pixel is supported. Expecco uses the libjpeg library, so any format supported by that (standard) library will also be supported by expecco.
PNG
(see http://www.schaik.com/pngsuite/pngsuite.html)
- Grayscale + alpha: reading unsupported (as of 2.11)
- 16bit RGB + alpha: incorrect display
- tRNS chunk with alpha values (only on-off masks)
When writing, expecco will always generate either 8bpp palette, or 24bpp truecolor images.
BMP
1, 4, 8, 24 and 32 bpp files can be read and written.
TIFF
Most formats are supported in reading, with some limitations:
- supported compressions:
- CCITT group3 FAX compression
- LZW
- packbits
1, 4, 8 and 24 bit files can be written. Data is always written uncompressed. No support for image masks or alpha channels.
XBM
Both, reading and writing
XPM
Some restrictions apply (to be documented)
Other Formats
Support for other formats, which are more or less of historic interest, can be made available upon request and at some extra charge: XWD, Targa, Sun-Raster, PICT, PCX, PBM, OSX-Icon, IrisRGB. Also, subset of the AVI and FLI formats can be provided if there is a need.