In logic, an
Image object facilitates the storing and manipulating of images. Image objects can contain photos, signatures, or other kinds of visual media. CSPro supports reading and writing to JPEG, PNG, and BMP image formats.
Function | Description |
load | Reads an image from a file and stores its contents in the Image object. |
save | Writes the contents of the Image object to a file. |
width | Returns the width of the image in pixels. |
height | Returns the height of the image in pixels. |
resample | Resamples the image to change the image's dimensions. |
createQRCode | Creates a QR code representing a text string. |
takePhoto | Takes a photo using a device's camera and stores the photo in the Image object. (Android only.) |
captureSignature | Allows the drawing of a signature and stores the captured signature in the Image object. (Android only.) |
view | Displays the image held by the object. |
clear | Clears the Image object's contents. |
|
getLabel | Returns the symbol's label. |
getName | Returns the symbol's name. |
getJson | Returns the symbol's metadata and value represented in JSON. |
getValueJson | Returns the symbol's value represented in JSON. |
updateValueFromJson | Modifies the symbol based on a JSON representation of the value. |
In addition to these object functions, Image objects can be used as arguments to the
filename and
view functions.
Image objects can be assigned to other Image objects, which will replace the Image's contents with the contents from the assigned Image object.
image_name = another_image_name;
It is also possible to assign Image objects to a
Document:
document_name = image_name;
You can also make the reverse assignment, assigning a document to an Image object. A runtime error will occur if the Document's data was not a valid image.
image_name = document_name;
Image roof_photo;
if roof_photo.takePhoto("Take a photo of the household's roof.") then
// in case the device's camera takes photos with an unnecessarily
// large resolution, resample the image to a more reasonable size
roof_photo.resample(maxWidth := 1600, maxHeight := 1200);
// save the image using the household key...
string base_filename = Path.concat(application, "Roof Photos", key(HH_DICT));
// ...with 90 quality to prevent the JPEG from being too large
roof_photo.save(base_filename + ".jpg", quality := 90);
endif;