| Did you know ... | Search Documentation: |
| Send methods |
new(I, image(File)).
The constructor first looks File up in @images;
on a hit it returns the existing instance. Otherwise it builds a new
image and image->loads
its pixels from the file. Such images get image<-access read.new(I, image(@nil, Width, Height)). These images are not
pooled and have image<-access both.
The kind argument selects between pixmap
(default) and
bitmap.
->load <-lookupsource_sink. When the
source is a file, it is first located via file->find
on
path (defaults to image.path).
The decoder is SDL_image, so PNG, JPEG, BMP, GIF, PCX and the other formats supported by SDL_image all load. SVG is recognised by file extension or by sniffing the stream and is rendered through SDL's size-aware SVG loader:
<-width and image<-height
non-zero → SVG is rendered at exactly that size;Streams that are not SVG fall back to a built-in PNM reader when SDL_image cannot interpret them.
format is omitted, the
extension of the file selects it (e.g., .jpg
or .jpeg for JPEG); an extension that is not one of these
formats writes PNG. quality is used by the lossy formats
JPEG, WebP and AVIF; the default is 90. JPEG and BMP have no
transparency. GIF has 256 colours. Whether WebP and AVIF are available
depends on how SDL_image was built (see display<-image_save_formats):
if not, image->save
fails with a message on the console.
For example:
?- send(Image, save, 'photo.jpg'), send(Image, save, 'small.webp', webp, 50).
in defaults to image<-file,
the file the image was loaded from. That is a source_sink rather than a
file: if it is not something we can write to, image->save
fails with a message on the console.
<-scale.|sdl_texture.g.,
the current frame of a camera into an existing image. Use image->draw_in
to blit an image into a sub-area instead.graphical (or image) onto the
receiver at the given offset (default point(0,0)).pixmap, 0 for bitmap).|bool(x, y) to the given colour (for pixmap)
or boolean (for bitmap).alpha < 255).