Description of MUSHclient world function: world.WindowLoadImage
||Loads an image into a miniwindow from a disk file
long WindowLoadImage(BSTR WindowName, BSTR ImageId, BSTR FileName);
View list of data type meanings
This loads the specified image into the miniwindow, and remembers it by the nominated "image id". The image id is later used for drawing this image. Loading does not draw it, it simply reads it from disk ready for drawing later.
Also see below in the Lua notes for WindowLoadImageMemory which loads an image loaded into memory.
WindowName - the name of an existing miniwindow.
ImageId - the image id to be associated with this particular image.
FileName - the disk file to load the image from. It should be a BMP or PNG file, not a GIF, TIF or other file type. If the filename is the empty string (ie. "") then any existing image matching the ImageId is deleted.
For more information, see:
If the loaded image is a PNG file, then it will have 24 bits per pixel if it does not have an alpha channel, and 32 bits per pixel if it has an alpha channel. You can use WindowImageInfo with selector 6 to find the number of bits per pixel of the loaded image.
Note: Available in version 4.34 onwards.
WindowLoadImage (win, "im1", "C:/program files/mushclient/leaf.bmp")
WindowLoadImage (win, "im2", "C:/program files/mushclient/background.png")
From version 4.42 onwards, Lua also supports WindowLoadImageMemory which loads an image file loaded into a memory buffer.
In this case the third argument is the memory buffer, not the file name.
local f = assert (io.open ("sword.png", "rb"))
local image_data = f:read ("*a") -- read all of it
f:close () -- close it
WindowLoadImageMemory (win, "im", image_data) -- load image from memory
WindowDrawImage (win, "im", 20, 20, 0, 0, 1) -- draw it
For WindowLoadImageMemory only PNG files are supported, not BMP ones.
WindowLoadImageMemory also supports an optional fourth argument. If true, the blue channel is swapped with the alpha channel. Thus, code like below would load the image into "ima", and then show it in the miniwindow, showing only the alpha mask:
WindowLoadImageMemory (win, "ima", image_data, true)
WindowBlendImage (win, "ima", 0, 0, 0, 0, 59, 1)
eNoSuchWindow - no such miniwindow
eFileNotFound - specified file was not found
eUnableToLoadImage - can't load image - perhaps it is not a BMP or PNG file
eOK - completed OK
View list of return code meanings
|Introduced in version
See also ...
Search for script function
Enter a word or phrase in the box below to narrow the list down to those that match.
The function name, prototype, summary, and description are searched.
Leave blank to show all functions.
Many functions return a "code" which indicates the success or otherwise
of the function.
view a list of the return codes
The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).
view a list of the data types used in function prototypes
View all functions
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.
Gammon Software support
Forum RSS feed ( https://gammon.com.au/rss/forum.xml )