class image

superclass(es) object
subclass(es) -
description The image class can be used for loading and displaying of bitmap images.

pl_img54.gif (4259 bytes)
see also canvas - imageButton

tasks

With the image class internal bitmaps and external bitmap files can be loaded. It is possible to resize and change the colors of the image, to convert an image to monochrome and back to color. Pasting and copying from and to the clipboard is also possible.
To draw an image on a panel window an instance of the class canvas must be used.

A distribution of Trinc-Prolog always contains the following bitmap images:

  • 'TP_BTN_OK'
  • 'TP_BTN_CLOSE'
  • 'TP_BTN_CANCEL'
  • 'TP_BTN_HELP'

These images can be loaded with the method load/2.

%Example: loading internal images and assigning them to image button instances

always(Img new_obj image, del_obj Img),
Img<-load('TP_BTN_OK', true),
OKBtn<-putImage(Img),
Img<-load('TP_BTN_CANCEL', true),
CancelBtn<-putImage(Img),
Img<-load('TP_BTN_HELP', true),
HelpBtn<-putImage(Img)

 

methods

isEmpty(Output)

func Determine if an image was loaded or if the instance is empty.
pre TRUE.
post If the image instance contains no picture then true is assigned to the variable Output, else false is assigned.

copyFrom(Image, Output)

func Copy the contents of the image instance refered to by the variable Image to the instance that executes the method.
pre The variable Image must refer to an instance of the image class.
post If the copying was successful then true is assigned to the variable Output, else false is assigned.

load(Name, Output)

func Load an image from the own executable file.
pre The variable Name must contain a string value.
post If the loading was successful then true is assigned to the variable Output, else false is assigned.
arrow.gif (1632 bytes) The following images are always included in a distribution of Trinc-Prolog:
  • 'TP_BTN_OK'
  • 'TP_BTN_CLOSE'
  • 'TP_BTN_CANCEL'
  • 'TP_BTN_HELP'

loadExternal(FileName, Output)

func Load an image from an external bitmap file. The current format supported is Windows bitmap, usually these files have the .bmp extension.
pre The variable Name must contain a string value.
post If the loading was successful then true is assigned to the variable Output, else false is assigned.

invert(Output)

func Invert the image.
pre TRUE.
post If inverting the image successful then true is assigned to the variable Output, else false is assigned.

toMono(R, G, B, Output)

func Convert a color image to a monochrome image. All pixels with the color equal to (R, G, B) are converted to white pixels, the rest of the pixels are made black.
pre The variables R, G and B must contain integer values which must be in the range [0, 255].
post If converting the image successful then true is assigned to the variable Output, else false is assigned.

isMono(Output)

func Determine if the image is a monochrome image or not.
pre TRUE.
post If the image is a monochrome image then true is assigned to the variable Output, else false is assigned.

toColor(R1, G1, B1, R0, G0, B0, Output)

func Convert a monochrome image to a color image, all 1 pixels in the monochrome image are converted to color pixels with the color( R1, G1, B1) and all 0 pixels are converted to (R0, G0, B0) pixels.
pre The variables R1, G1, B1, R0, G0 and B0 must contain integer values which must be in the range [0, 255].
post If converting the image successful then true is assigned to the variable Output, else false is assigned.

removeColor(R, G, B, RNew, GNew, BNew, Output)

func Remove a single color from the image, all pixels with the color (R, G, B) are replaced by pixels with the color (RNew, GNew, BNew).
pre The variables R, G, B, RNew, GNew and BNew must contain integer values which must be in the range [0, 255].
post If removing the color was successful then true is assigned to the variable Output, else false is assigned.

copy(Output)

func Copy the image to the clipboard.
pre TRUE.
post If copying the image to the clipboard was successful then true is assigned to the variable Output, else false is assigned.

paste(Output)

func Paste the image from the clipboard into the image instance.
pre The clipboard must contain a bitmap image.
post If pasting the image from the clipboard was successful then true is assigned to the variable Output, else false is assigned.

dimensions(point(X, Y))

func Retrieve the dimensions of the image.
pre TRUE.
post The width and height of the image were assigned to the variables X and Y.

resize(point(X, Y), Output)

func Change the dimensions of the image.
pre The variables X and Y must contain integer values.
post If resizing the image was successful then true is assigned to the variable Output, else false is assigned.