SetPicture

Description

Assigns an image stored in a blob to be the image in a Picture control.

Applies to

Picture controls

Syntax

picturecontrol.SetPicture ( bimage )

Argument

Description

picturecontrol

The name of a Picture control in which you want to set the bitmap.

bimage

A blob containing the new bitmap. bimage must be a valid picture in bitmap (BMP), Compuserve Graphics Interchange Format (GIF), Joint Photographic Experts Group (JPEG), run-length encoded (RLE), or Windows Metafile (WMF).

Returns

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 32765 characters at a time. To check the length of a file, call FileLength. If the file is over 32765 characters, you can call FileRead more than once and concatenate the return values.

Examples

Example 1

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:

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