WindowMergeImageAlpha
Script function

world.WindowMergeImageAlpha

DOC_scripting Read about scripting

Type

Method

Summary

Merges an image into a miniwindow based on an alpha mask

Prototype

long WindowMergeImageAlpha(BSTR Name, BSTR ImageId, BSTR MaskId, long Left, long Top, long Right, long Bottom, short Mode, double Opacity, long SrcLeft, long SrcTop, long SrcRight, long SrcBottom);

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

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:

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



Lua example

WindowMergeImageAlpha (win, "castle", "mask", 
                       0, 0, 0, 0,   -- full image
                       1, 1,            -- use transparency, 100% opacity
                       0, 0, 0, 0)  -- source offset



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


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_WindowLoadImage WindowLoadImage (Loads an image into a miniwindow from a disk file)
FNC_WindowMenu WindowMenu (Creates a pop-up menu inside a miniwindow)
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=WindowMergeImageAlpha)

DOC_contents Documentation contents page