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

MUSHclient scripting

Description of MUSHclient world function: world.WindowMergeImageAlpha


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


Note: Available in 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
Returns 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

Introduced in version 4.36

See also ...

Function Description
WindowBlendImage Blends an image into a miniwindow, using a specified blending mode
WindowGetImageAlpha Draws the alpha channel of an image into a miniwindow
WindowLoadImage Loads an image into a miniwindow from a disk file

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]