[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.WindowLoadImage


Name WindowLoadImage
Type Method
Summary Loads an image into a miniwindow from a disk file
Prototype long WindowLoadImage(BSTR WindowName, BSTR ImageId, BSTR FileName);

View list of data type meanings

Description

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:

http://www.gammon.com.au/mushclient/mw_images.htm

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.


Lua example
WindowLoadImage (win, "im1", "C:/program files/mushclient/leaf.bmp")
WindowLoadImage (win, "im2", "C:/program files/mushclient/background.png")
Lua notes
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)
Returns 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 4.34

See also ...

Function Description
WindowCreate Creates a miniwindow
WindowCreateImage Creates an image in a miniwindow
WindowDrawImage Draws an image into a miniwindow
WindowImageInfo Returns information about an image
WindowImageList Lists all images installed into a miniwindow
WindowImageOp Draws an ellipse, rectangle or round rectangle, filled with an image

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.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]