MaskCopy

The MaskCopy method copies image from active imagespace (top level, source image) over image in inactive imagespace (bottom level, destination image) using mask as a transparency factor for top level image. Mask should previously be created using the CreateMask method

CreateMask [xMask][, yMask][, xSource][, ySource]

Parameters

xMask
Optional. Specifies horizontal position of mask image relatively top left corner of destination image. Default is 0.
yMask
Optional. Specifies vertical position of mask image relatively top left corner of destination image. Default is 0.
xSource
Optional. Specifies horizontal position of source image relatively top left corner of destination image. Default is 0.
ySource
Optional. Specifies vertical position of source image relatively top left corner of destination image. Default is 0.

Remarks

Mask imagespace is a special imagespace where ShotGraph keeps grayscale mask. Every pixel of mask defines transparency level for the corresponding pixel of top level image. Lighter mask pixels are more transparent for top level image. Image mask acts as a irregularry smoked glass between top and bottom images. Using parameters you can move both mask and top level image relatively destination image.

Examples
The first example resizes image and places white vignette (with diagonal green line) around it. The second example gets image and places white vignette around it. Both two examples read grayscale mask from the file.
Example1
This example makes image thumbnail and places white vignette (with diagonal green line) around it. Image mask are read from the file, top level image (white background with green line) is drawn.
View result

Set g = CreateObject("shotgraph.image")

source = "ship.jpg"
mask = "mask.jpg"
' Rectangle for thumbnail image
newwidth = 200
newheight = 200

' Get size of source and mask images
g.GetFileDimensions source,swidth,sheight
g.GetFileDimensions mask,mwidth,mheight

' Calculate size of thumbnail image
if swidth / newwidth > sheight / newheight then
	newheight = sheight * newwidth \ swidth
else
	newwidth = swidth * newheight \ sheight
end if

' Create primary imagespace for thumbnail image
g.CreateImage newwidth,newheight,256

' Create secondary imagespace for original mask...
g.InitClipboard mwidth,mheight
' and resize mask to future thumbnail size
g.SelectClipboard True
g.ReadImage mask,palette,0,0
g.Stretch 0,0,newwidth,newheight,0,0,mwidth,mheight,"SRCCOPY","HALFTONE"
g.SelectClipboard False
' Now mask is in the primary imagespace, copy it to mask imagespace
g.CreateMask

' Create secondary imagespace for original image...
g.InitClipboard swidth,sheight
' and resize image to future thumbnail size, as required
g.SelectClipboard True
g.ReadImage source,palette,0,0
g.Stretch 0,0,newwidth,newheight,0,0,swidth,sheight,"SRCCOPY","HALFTONE"
g.SelectClipboard False
' Now resized original image is in the primary imagespace

' Create secondary imagespace for top level image
g.InitClipboard newwidth,newheight
g.SelectClipboard True
' Draw on secondary imagespace (top level image)
g.SetColor 0,255,255,255
g.SetColor 1,0,153,0
g.SetBgColor 0
g.SetDrawColor 1
' Fill with white
g.FillRect 0,0,newwidth,newheight
' Draw diagonal green line
g.Line 0,0,newwidth,newheight
' Copy secondary imagespace through mask onto primary imagespace
g.MaskCopy
g.SelectClipboard False

g.JpegImage 90,0,"maskcopy1.jpg"
Example2
This example reads image and places white vignette (with diagonal green line) around it. Image mask are read from the file, top level image (white background) is drawn.
View result

Set g = CreateObject("shotgraph.image")

source = "ship.jpg"
mask = "mask.jpg"

' Get size of source and mask images
g.GetFileDimensions source,swidth,sheight
g.GetFileDimensions mask,mwidth,mheight

' Create primary imagespace for image
g.CreateImage swidth,sheight,256

' Create secondary imagespace for original mask...
g.InitClipboard mwidth,mheight
' and resize mask to original image size
g.SelectClipboard True
g.ReadImage mask,palette,0,0
g.Stretch 0,0,swidth,sheight,0,0,mwidth,mheight,"SRCCOPY","HALFTONE"
g.SelectClipboard False
' Now mask is in the primary imagespace, copy it to mask imagespace
g.CreateMask

' Read original image (to the primary imagespace)
g.ReadImage source,palette,0,0
' Now original image is in the primary imagespace

' Create secondary imagespace for top level image
g.InitClipboard swidth,sheight
g.SelectClipboard True
' Draw on secondary imagespace (top level image)
g.SetColor 0,255,255,255
g.SetBgColor 0
' Fill with white
g.FillRect 0,0,swidth,sheight
' Copy secondary imagespace through mask onto primary imagespace
g.MaskCopy
g.SelectClipboard False

g.JpegImage 90,0,"maskcopy2.jpg"