Platforms to show: All Mac Windows Linux Cross-Platform

/Main/Duplicate Picture with Mask


Required plugins for this example: MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Main/Duplicate Picture with Mask

This example is the version from Sun, 17th Mar 2012.

Project "Duplicate Picture with Mask.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
Control Canvas2 Inherits Canvas
ControlInstance Canvas2 Inherits Canvas
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim pic as Picture = LogoMBS(300) dim mask as Picture = pic.mask dim g as Graphics = mask.Graphics g.ForeColor = &cFFFFFF g.FillRect 0,0,g.Width,g.Height g.ForeColor = &c000000 g.FillOval 0,0,g.Width,g.Height canvas1.Backdrop = pic canvas2.Backdrop = pic.Duplicate End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim pic as Picture = LogoMBS(300) canvas1.Backdrop = pic canvas2.Backdrop = pic.Duplicate End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() #if RBVersion >= 2011.04 then dim pic as Picture = LogoMBS(300, true) dim m as new Picture(300, 300) dim g as Graphics = m.Graphics g.ForeColor = &cFFFFFF g.FillRect 0,0,g.Width,g.Height g.ForeColor = &c000000 g.FillOval 0,0,g.Width,g.Height pic.ApplyMask m canvas1.Backdrop = pic canvas2.Backdrop = pic.Duplicate #else MsgBox "not supported." #endif End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Module Module1
Function Duplicate(extends p as Picture) As Picture #if RBVersion >= 2011.04 then if p.HasAlphaChannel then // create nw picture and copy content: dim q as new Picture(p.Width, p.Height) q.Graphics.DrawPicture p,0,0 Return q end if #endif // create new picture dim q as new Picture(p.Width, p.Height, 32) // get mask dim oldMask as Picture = p.mask(false) if oldMask = nil then // no mask, so simple copy q.Graphics.DrawPicture p,0,0 Return q end if // remove mask p.mask = nil // copy picture and mask q.Graphics.DrawPicture p, 0, 0 q.mask.Graphics.DrawPicture oldMask,0,0 // restore mask p.mask = oldmask Return q End Function
End Module
End Project

The items on this page are in the following plugins: MBS Main Plugin.


The biggest plugin in space...