Draws one image from a ListImages collection over another, and returns the result.
ImageList.Overlay (index1, index2)
index1, index2:Variant
The Overlay method combines two images and returns a new Picture object. index1 is an integer (Index property) or unique string (Key property) that specifies the image to be overlaid. index2 specifies the image to be drawn over the object specified in index1. The color of the image that matches the MaskColor property is made transparent. If no color matches, the image is drawn opaquely over the other image.
// Create two pictures to be overlaid
OpenW 1 : Win_1.AutoRedraw = 1
Color 255 : Draw 0, 0 To 100, 0 To 0, 100 To 0, 0 : Fill 10, 10
Color RGB(255, 255, 255), 255 : Text 10, 10, "GFABasic"
Color RGB(0, 255, 0) : Draw 201, 0 To 201, 100 To 101, 100 To 201, 0 : Fill 190, 90
Color RGB(255, 255, 0), RGB(255, 255, 255) : Text 111, 10, "GFABasic"
Local Handle h1, h2 : Local Picture p1, p2, p3, p4
Get 0, 0, 100, 100, h1 : Set p1 = CreatePicture(h1, False)
Get 101, 0, 200, 100, h2 : Set p2 = CreatePicture(h2, False)
Cls
// Create Imagelist
Ocx ImageList iml
iml.MaskColor = RGB(255, 255, 255)
iml.UseMaskColor = True
iml.Add , "First", p1
iml.Add , "Second", p2
// Draw the two listimages
// (Note the 'greyed' transparent area)
iml(1).Draw Win_1.hDC, 0, 0
iml(2).Draw Win_1.hDC, 105, 0
// Create the composite image, first by using the index...
Set p3 = iml.Overlay(1, 2)
// ...and then by using the unique Key.
Set p4 = iml.Overlay("First", "Second")
// Display the two composite images
PaintPicture p3, 0, 150
PaintPicture p4, 105, 150
Use the Overlay method in conjunction with the MaskColor property to create a single image from two disparate images. The Overlay method imposes one bitmap over another to create a third, composite image. The MaskColor property determines which color of the overlaying image is transparent.
ImageList, ListImages, Picture
{Created by Sjouke Hamstra; Last updated: 21/10/2014 by James Gaite}