Loads a graphic and returns a Picture object
LoadPicture([filename$] [, x, y, c])
filename$:sexp
x, y, c:iexp
LoadPicture loads a picture file indicated by filename$ and returns a Picture object. The return value can be assigned directly to object properties that take a .Picture reference, using Set =. Examples are Form.Picture, Ocx.MouseIcon, Command.Picture, etc.
Graphics formats recognized by LoadPicture include bitmap (.bmp) files, icon (.ico) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif) files, and JPEG (.jpg) files.
Graphics are cleared from forms, picture boxes, and image controls by assigning LoadPicture with no argument.
To assign an icon to a form, set the return value of the LoadPicture function to the Icon property of the Form object: Set Form.Icon = LoadPicture(icon$).
The optional arguments x, y, and c are used only with icon and cursor files. These icon files often contain several images with different size and color formats. To get the required icon from several different ones, the LoadPicture takes size and color arguments:
Set Form.SmallIcon = LoadPicture("ico-name.ico", x, y, c)
If filename is a cursor or icon file, and either x or y is specified, the x and y specify the width or height desired. In a file containing multiple separate images, the best possible match is used if an image of that size is not available. X and y values are only used when c (color depth) is > 1. For icon files 255 is the maximum possible value.
If both x =0 and y = 0, a small icon will be loaded (mostly 16x16).
If x or y is equal 0 and y or x = 1, the default 32x32 large icon will be loaded (actually determined by the video driver).
If c = 0 the default colors are used and a best available match is made.
If c = 1 a monochrome image is searched and loaded.
If c => 2 searches for an image with the specified number of colors.
Local bmp As Picture, n As Int32
Ocx Form test
AutoRedraw = True
// Find picture file
Local d$ = GetSetting("\\HKEY_CLASSES_ROOT\g32File\shell\open\command", , "")
If Left(d$, 1) = #34 Then d$ = Mid(d$, 2)
n = RInStr(d$, "\") : If n <> 0 Then d$ = Left(d$, n - 1)
d$ = d$ & "\..\samples\bitmaps\splash.bmp"
Print d$
If Not Exist(d$) Then _
MsgBox("Can not locate Splash.bmp file"#13#10#13#10"Please manually place it in the GFABASIC32\Samples\Bitmaps folder and try again.") : End
// Load the picture
Set bmp = LoadPicture(d$)
// Show the picture and stretch it over the whole form
PaintPicture bmp, 0, 0, _X, _Y
Do
Sleep
Until Me Is Nothing // Alt + F4
Set bmp = Nothing
Pictures stored in the :File section can be loaded with LoadPicture but it should be noted that, to achieve this, GFABasic copies it to the temporary directory first and then loads it into memory from this newly created physical file. This is due to the fact that LoadPicture can not handle the 'unpacking' of the file. When loading big files (BMP, JPEG, GIF) this will increase the load time, although with technology as it is, this may not be either significant or noticeable.
GFA-BASIC 32 also supports the conversion of normal API bitmaps to an OLE Picture object with the CreatePicture function.
PaintPicture, SavePicture, CreatePicture
{Created by Sjouke Hamstra; Last updated: 25/07/2020 by James Gaite}