Script function
world.WindowMergeImageAlpha
Read about scripting
Type
Method
Summary
Merges an image into a miniwindow based on an alpha mask
Prototype
long WindowMergeImageAlpha(BSTR WindowName, BSTR ImageId, BSTR MaskId, long Left, long Top, long Right, long Bottom, short Mode, double Opacity, long SrcLeft, long SrcTop, long SrcRight, long SrcBottom);
View list of data type meanings
Description
This merges the previously-loaded image identified by ImageId onto the miniwindow, based on the opacity of the mask MaskId. The mask must be large enough to cover the requested area in the blended image.
One method of setting up a mask would be to use the WindowGetImageAlpha function to obtain the alpha information from an image. Alternatively you might have the alpha information in a separate image file.
Each colour (red/green/blue) in the mask is individually considered when merging each pixel. If the mask is white (ie. 255) for that colour, then the blended image is used. If the mask is black (ie. 0) then the base image is preserved. In between, the blended image is used to the extent of the value (for example, 128 would be a 50% blend).
You can use a mask with a soft border (eg. by blurring it) to make a soft transition between the loaded image and the existing contents of 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, or Redraw.
Parameters:
WindowName - the name of an existing miniwindow.
ImageId - an image id that you have previously loaded.
MaskId - an image id for the mask, which has been previously loaded.
Left, Top, Right, Bottom - describes the destination rectangle. The blend image is merged with the contents of this rectangle to produce the blended result.
Mode - the blending method.
0 = straight blend
1 = transparent blend - the pixel at 0,0 in the ImageId image will be taken as the transparency colour.
Opacity - the amount of opacity, between 0 and 1 (floating-point number). An opacity of 0 means you will not see the merged image. An opacity of 1 means the merge is fully applied. An opacity of 0.5 means the masked, merged image is merged 50% with the original contents of the miniwindow.
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.
When blending, whichever rectangle is smaller is the one used for the width and height of the operation (the destination rectangle or the source rectangle).
Available in MUSHclient version 4.36 onwards.
Lua example
WindowMergeImageAlpha (win, "castle", "mask",
0, 0, 0, 0, -- full image
1, 1, -- use transparency, 100% opacity
0, 0, 0, 0) -- source offset
Lua notes
You can use the following constants for the mode:
miniwin.merge_straight = 0
miniwin.merge_transparent = 1
Return value
eBadParameter - Opacity not in range 0 to 1, or mask not large enough
eImageNotInstalled - Either the blend image or the mask image is not installed
eNoSuchWindow - No such miniwindow
eUnknownOption - Mode not in list above
eOK - success
View list of return code meanings
See Also ...
Topic
MiniWindows
Functions
(GetDeviceCaps) Gets screen device capabilities
(SetCursor) Changes the shape of the mouse cursor
(TextRectangle) Specifies the size of the rectangle in which text is displayed in the output window.
(WindowAddHotspot) Adds a hotspot to a miniwindow
(WindowArc) Draws an arc in a miniwindow
(WindowBezier) Draws a Bézier curve in a miniwindow
(WindowBlendImage) Blends an image into a miniwindow, using a specified blending mode
(WindowCircleOp) Draws ellipses, filled rectangles, round rectangles, chords, pies in a miniwindow
(WindowCreate) Creates a miniwindow
(WindowCreateImage) Creates an image in a miniwindow
(WindowDelete) Deletes a miniwindow
(WindowDeleteAllHotspots) Deletes all hotspots from a miniwindow
(WindowDeleteHotspot) Deletes a hotspot from a miniwindow
(WindowDragHandler) Adds a drag handler to a miniwindow hotspot
(WindowDrawImage) Draws an image into a miniwindow
(WindowDrawImageAlpha) Draws an image into a miniwindow respecting the alpha channel
(WindowFilter) Performs a filtering operation over part of the miniwindow.
(WindowFont) Loads a font into a miniwindow
(WindowFontInfo) Returns information about a font
(WindowFontList) Lists all fonts loaded into a miniwindow
(WindowGetImageAlpha) Draws the alpha channel of an image into a miniwindow
(WindowGetPixel) Gets the colour of a single pixel in a miniwindow
(WindowGradient) Draws a gradient in a rectangle
(WindowHotspotInfo) Returns information about a hotspot
(WindowHotspotList) Lists all hotspots installed into a miniwindow
(WindowHotspotTooltip) Changes the tooltip text for a hotspot in a miniwindow
(WindowImageFromWindow) Creates an image from another 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
(WindowInfo) Returns information about a miniwindow
(WindowLine) Draws a line in a miniwindow
(WindowList) Lists all miniwindows
(WindowLoadImage) Loads an image into a miniwindow from a disk file
(WindowMenu) Creates a pop-up menu inside a miniwindow
(WindowMoveHotspot) Moves a hotspot in a miniwindow
(WindowPolygon) Draws a polygon in a miniwindow
(WindowPosition) Moves a miniwindow
(WindowRectOp) Draws a rectangle in a miniwindow
(WindowResize) Resizes a miniwindow
(WindowScrollwheelHandler) Adds a scroll-wheel handler to a miniwindow hotspot
(WindowSetPixel) Sets a single pixel in a miniwindow to the specified colour
(WindowSetZOrder) Sets the Z-Order for a miniwindow
(WindowShow) Shows or hides a miniwindow
(WindowText) Draws text into a miniwindow
(WindowTextWidth) Calculates the width of text in a miniwindow
(WindowTransformImage) Draws an image into a miniwindow with optional rotation, scaling, reflection and shearing
(WindowWrite) Writes the contents of a miniwindow to disk as a graphics file
(Help topic: function=WindowMergeImageAlpha)