CreateMask
[xMask][, yMask][, xSource][, ySource]
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.
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"
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"