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

MUSHclient scripting

Description of MUSHclient world function: world.WindowDrawImage

Name WindowDrawImage
Type Method
Summary Draws an image into a miniwindow
Prototype long WindowDrawImage(BSTR WindowName, BSTR ImageId, long Left, long Top, long Right, long Bottom, short Mode, long SrcLeft, long SrcTop, long SrcRight, long SrcBottom);

View list of data type meanings


This copies an image to the miniwindow.

Note that changes to miniwindows will not become visible until the output window is redrawn. This happens when new (visible) lines arrive from the MUD, or if you call WindowShow, Repaint, or Redraw.


WindowName - the name of an existing miniwindow.

ImageId - an image id that you have loaded.

Left, Top, Right, Bottom - describes the rectangle to be drawn to.

Mode - the method of drawing the image:

1 - Copy without stretching to the destination position. The image is not clipped, so only the Left and Top parameters are used - the full image is copied to that position.

To copy less than the full image you would need to use the SrcLeft, SrcTop, SrcRight, SrcBottom parameters to specify a smaller part of the image.

2 - Stretch or shrink the image appropriately to fit into the rectangle: Left, Top, Right, Bottom.

3 - Copy without stretching to the position Left, Top. However this is a transparent copy, where the pixel at the left,top corner (pixel position 0,0) is considered the transparent colour. Any pixels that exactly match that colour are not copied. WARNING - do not choose black or white as the transparent colour as that throws out the calculations. Choose some other colour (eg. purple) - you won't see that colour anyway.

SrcLeft, SrcTop, SrcRight, SrcBottom - the source rectangle in the original image (use 0,0,0,0 to get the whole image). Negative numbers for the SrcRight and SrcBottom parameters represent an offset from the bottom or right edge.

The intention of allowing sub-images was so that you could make up a map by having lots of small images (eg. houses, trees, rocks). Now instead of having to load hundreds of tiny image files into memory, which would doubtless take a while to open all those files, you open a single, larger, file in which the various sub-images are "tiled". For example, you might allocate a 32 x 32 pixel square for each image. Now by selecting the appropriate tile you can copy the sub-image from the main image.

For more information, see:


To draw images which have alpha channels, see WindowDrawImageAlpha.

Note that if you draw a monchrome image, such as one set up by WindowCreateImage then the pen colour from the most recent drawing operation is used as the foreground colour, and the brush colour for the background colour. Thus you may want to draw a small rectangle (eg. 1 x 1 pixel) with WindowCircleOp to establish those colours first.

Note: Available in version 4.34 onwards.

Lua example
WindowDrawImage (win, "im", 20, 20, 0, 0, 1)  -- straight copy

WindowDrawImage (win, "im", 20, 20, -20, -20, 2)  -- stretch

WindowDrawImage (win, "im", 20, 20, -20, -20, 3)  -- transparent
Lua notes
You can use the following constants for the mode:

miniwin.image_copy = 1
miniwin.image_stretch = 2
miniwin.image_transparent_copy = 3
Returns eNoSuchWindow - no such miniwindow

eImageNotInstalled - that image was not loaded with WindowLoadImage or WindowLoadImageMemory

eBadParameter - drawing mode not in list above

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
WindowDrawImageAlpha Draws an image into a miniwindow respecting the alpha channel
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
WindowTransformImage Draws an image into a miniwindow with optional rotation, scaling, reflection and shearing

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


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.


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]