SetPicture
PowerScript function
Description
Assigns an image stored in a blob to be the image in a Picture
control.
Applies to
Picture controls
Syntax
|
1 |
picturecontrol.SetPicture ( bimage ) |
|
Argument |
Description |
|---|---|
|
picturecontrol |
The name of a Picture control in which you want to set the |
|
bimage |
A blob containing the new bitmap. bimage must be a valid |
Return value
Integer.
Returns 1 if it succeeds and -1 if an error occurs. If any
argument’s value is null, SetPicture returns null.
Usage
If you use FileRead to get the bitmap image from a file, remember
that the FileRead function can read a maximum of 32,765 bytes at a time.
To check the length of a file, call FileLength. If the file is over 32,765
bytes, you can call FileRead more than once and concatenate the return
values, or you can call FileReadEx.
For Unicode files and files that you convert to Unicode, you must
make sure that the file length value is an even number. Otherwise FileRead
or FileReadEx cannot parse the entire file.
Examples
These statements allow the user to select a file and then open the
file and set the Picture control p_1 to the bitmap in the selected
file:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
integer fh, ret blob Emp_pic string txtname, named string defext = "BMP" string Filter = "bitmap Files (*.bmp), *.bmp" ret = GetFileOpenName("Open Bitmap", txtname, & named, defext, filter) IF ret = 1 THEN fh = FileOpen(txtname, StreamMode!) IF fh <> -1 THEN FileRead(fh, Emp_pic) FileClose(fh) p_1.SetPicture(Emp_pic) END IF END IF |