WindowLoadImage
Script function

world.WindowLoadImage

DOC_scripting Read about scripting

Type

Method

Summary

Loads an image into a miniwindow from a disk file

Prototype

long WindowLoadImage(BSTR Name, BSTR ImageId, BSTR FileName);

DOC_data_types 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.

Name - 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.



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)



Return value

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


DOC_errors View list of return code meanings


See Also ...

Topic

DOC_miniwindows Mini Windows

Functions

FNC_GetDeviceCaps GetDeviceCaps (Gets screen device capabilities)
FNC_SetCursor SetCursor (Changes the shape of the mouse cursor)
FNC_TextRectangle TextRectangle (Specifies the size of the rectangle in which text is displayed in the output window.)
FNC_WindowAddHotspot WindowAddHotspot (Adds a hotspot to a miniwindow)
FNC_WindowArc WindowArc (Draws an arc in a miniwindow)
FNC_WindowBezier WindowBezier (Draws a Bézier curve in a miniwindow)
FNC_WindowBlendImage WindowBlendImage (Blends an image into a miniwindow, using a specified blending mode)
FNC_WindowCircleOp WindowCircleOp (Draws ellipses, filled rectangles, round rectangles, chords, pies in a miniwindow)
FNC_WindowCreate WindowCreate (Creates a miniwindow)
FNC_WindowCreateImage WindowCreateImage (Creates an image in a miniwindow)
FNC_WindowDelete WindowDelete (Deletes a miniwindow)
FNC_WindowDeleteAllHotspots WindowDeleteAllHotspots (Deletes all hotspots from a miniwindow)
FNC_WindowDeleteHotspot WindowDeleteHotspot (Deletes a hotspot from a miniwindow)
FNC_WindowDragHandler WindowDragHandler (Adds a drag handler to a miniwindow hotspot)
FNC_WindowDrawImage WindowDrawImage (Draws an image into a miniwindow)
FNC_WindowDrawImageAlpha WindowDrawImageAlpha (Draws an image into a miniwindow respecting the alpha channel)
FNC_WindowFilter WindowFilter (Performs a filtering operation over part of the miniwindow.)
FNC_WindowFont WindowFont (Loads a font into a miniwindow)
FNC_WindowFontInfo WindowFontInfo (Returns information about a font)
FNC_WindowFontList WindowFontList (Lists all fonts loaded into a miniwindow)
FNC_WindowGetPixel WindowGetPixel (Gets the colour of a single pixel in a miniwindow)
FNC_WindowGradient WindowGradient (Draws a gradient in a rectangle)
FNC_WindowHotspotInfo WindowHotspotInfo (Returns information about a hotspot)
FNC_WindowHotspotList WindowHotspotList (Lists all hotspots installed into a miniwindow)
FNC_WindowHotspotTooltip WindowHotspotTooltip (Changes the tooltip text for a hotspot in a miniwindow)
FNC_WindowImageFromWindow WindowImageFromWindow (Creates an image from another miniwindow)
FNC_WindowImageInfo WindowImageInfo (Returns information about an image)
FNC_WindowImageList WindowImageList (Lists all images installed into a miniwindow)
FNC_WindowImageOp WindowImageOp (Draws an ellipse, rectangle or round rectangle, filled with an image)
FNC_WindowInfo WindowInfo (Returns information about a miniwindow)
FNC_WindowLine WindowLine (Draws a line in a miniwindow)
FNC_WindowList WindowList (Lists all miniwindows)
FNC_WindowMenu WindowMenu (Creates a pop-up menu inside a miniwindow)
FNC_WindowMergeImageAlpha WindowMergeImageAlpha (Merges an image into a miniwindow based on an alpha mask)
FNC_WindowPolygon WindowPolygon (Draws a polygon in a miniwindow)
FNC_WindowPosition WindowPosition (Moves a miniwindow)
FNC_WindowRectOp WindowRectOp (Draws a rectangle in a miniwindow)
FNC_WindowSetPixel WindowSetPixel (Sets a single pixel in a miniwindow to the specified colour)
FNC_WindowShow WindowShow (Shows or hides a miniwindow)
FNC_WindowText WindowText (Draws text into a miniwindow)
FNC_WindowTextWidth WindowTextWidth (Calculates the width of text in a miniwindow)
FNC_WindowWrite WindowWrite (Writes the contents of a miniwindow to disk as a graphics file)

(Help topic: function=WindowLoadImage)

DOC_contents Documentation contents page