PDA

View Full Version : Example: Free tool : Dynamic Masking Tool


clueless
12-06-2006, 12:50 PM
This tool (http://www.fataloverdose.copperstream.co.uk/files/programming_tools/dmt/dmt_full.rar) is for mixing custom window masks dynamically. Its a command line tool written in visual basic 6 that takes the white elements from one bmp and then add/remove them from another bmp. This allows you make 'draws' that extend outwards from your main program window.http://www.fataloverdose.copperstream.co.uk/files/programming_tools/dmt/dmt_examplepic_web.gif
Eventually ill be making this into a DLL file.

Format:

Add the white elements of MaskA into MaskB. MaskB is then re-saved

DMT [Location of Draw Mask] [location of main custom mask]


Remove the white elements of MaskA from Mask B. MaskB is then re-saved
DMT [Location of Draw Mask] [location of main custom mask] [remove]

Here's an example of how to set up the process in code;

function CompositeMasks(DrawNumb)

---------------------------
------------ initialise local variables ----------------
local CheckFile = 0;
local FileSize = File.GetSize(_SourceFolder.."\\AutoPlay\\Mix\\CustomMask.bmp");

--------------------------------------
------------ Run tool and pass the command line ----------------
File.Run("AutoPlay\\Mix\\composite.exe", ConstructCommandLine(DrawNumb), "", SW_SHOWNORMAL, true); -- run composite tool with commandline pointing to the mix folder

-------------------------------------------------------------------
------------ Check for main file to change size then use it for windown mask ----------------

while CheckFile < 50 do -- check 50 times then give up -- Checks for a change in file size 50 times
if File.DoesExist("AutoPlay\\Mix\\CustomMask.bmp") and (File.GetSize("\\AutoPlay\\Mix\\CustomMask.bmp") ~= CheckFile) then -- File size check against value recorded before running the composite tool
Window.SetMask(Application.GetWndHandle(), "AutoPlay\\Mix\\CustomMask.bmp", true, 0); -- If the file has chaged size then set it as the new mask
break -- Dumps out of the 'while' loop
else
CheckFile = CheckFile + 1; -- Increments the counter
end
end
end

-----------------------------------------------------
-------------------------------------------------------------------------------.
------------ Set up the commandline -----------------------------
---------------------------------------------------
function ConstructCommandLine(DrawNumb)

local CommandLine = -1;

if DrawNumb == 1 then
CommandLine = _SourceFolder.."\\AutoPlay\\Images\\Left.bmp";
elseif DrawNumb == 2 then
CommandLine = _SourceFolder.."\\AutoPlay\\Images\\Bottom.bmp";
elseif DrawNumb == 3 then
CommandLine = _SourceFolder.."\\AutoPlay\\Images\\Right.bmp";
end

CommandLine = CommandLine .. "#"; -- Adding a space before adding the main mask location
CommandLine = CommandLine .. _SourceFolder.."\\AutoPlay\\Mix\\CustomMask.bmp"; -- Adding the location of the main Mask

-- Only checking for
if Draw[DrawNumb] == 1 then --
Draw[DrawNumb] = 0 -- Toggles draw open/close state
CommandLine = CommandLine .."#"; -- Adding a space
CommandLine = CommandLine .."remove"; -- Add the flag to remove white pixels (by adding black) rather than write them
else --
Draw[DrawNumb] = 1 -- Toggles draw open/close state
CommandLine = CommandLine .."#"; -- Adding a space
CommandLine = CommandLine .."Add"; -- Add the flag to add white pixels rather than remove them
end
return CommandLine
end


Have fun ..

clueless
02-04-2008, 12:44 PM
This tool has now been uprated to version 2 : Download the DMT v2.0 (http://www.fataloverdose.copperstream.co.uk/files/programming_tools/DMT_Clueless.rar) Info (http://www.indigorose.com/forums/showthread.php?t=22729)