(AGK version: 108.24)
Submitted: 2015-02-17 18:53:45
// set window properties
SetWindowTitle( "image mask" )
SetWindowSize( 1024, 768, 0 )

// set display properties
SetVirtualResolution( 1024, 768 )
SetClearColor(45,0,0)

#constant _RedChannel   1
#constant _GreenChannel 2
#constant _BlueChannel  3
#constant _AlphaChannel 4

_White  = MakeColor(255,255,255)
_Red    = MakeColor(175,0,0)
_Yellow = MakeColor(175,175,0)
_Green  = MakeColor(0,175,0)
_Blue   = MakeColor(0,0,175)

Render()
DrawBox(100,100,200,200,_Red,_Red,_Red,_Red,1)
DrawBox(200,100,300,200,_Green,_Green,_Green,_Green,1)
DrawBox(100,200,200,300,_Blue,_Blue,_Blue,_Blue,1)
DrawBox(200,200,300,300,_Yellow,_Yellow,_Yellow,_Yellow,1)

DrawBox(200,300,400,500,0,0,0,0,1)

Render()

_Boxes       = GetImage(100,100,500,200)
_RenderImage = GetImage(200,300,400,500)

_BoxesSpr = CreateSprite(_Boxes)
SetSpritePosition(_boxesSpr, 100,100)

_renderSpr = CreateSprite(_RenderImage)
SetSpritePosition(_renderSpr, 400,100)

SetImageMask(_RenderImage, _Boxes, _RedChannel,  _RedChannel,  0, 0 )	
SetImageMask(_RenderImage, _Boxes, _GreenChannel,_GreenChannel,0, 0 )
SetImageMask(_RenderImage, _Boxes, _BlueChannel,_BlueChannel,0, 0 )


SetPrintSize(18)
do 	
print("Left is the Source image, Right is the destination image which was originaly blank.")
   print("Notice how the yellow colour is blended automaticaly")
   
	sync()
loop
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.