Platforms to show: All Mac Windows Linux Cross-Platform

/Images/LargePicture/Matrix


Required plugins for this example: MBS Images Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/LargePicture/Matrix

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

Project "Matrix.xojo_binary_project"
Class main Inherits Window
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() img_reset init_pmx img_proc out.Backdrop=dest.CopyPicture End EventHandler
End Control
Control param Inherits int_only
ControlInstance param(0) Inherits int_only
ControlInstance param(1) Inherits int_only
ControlInstance param(2) Inherits int_only
ControlInstance param(3) Inherits int_only
ControlInstance param(4) Inherits int_only
ControlInstance param(5) Inherits int_only
ControlInstance param(6) Inherits int_only
ControlInstance param(7) Inherits int_only
ControlInstance param(8) Inherits int_only
ControlInstance param(9) Inherits int_only
ControlInstance param(10) Inherits int_only
ControlInstance param(11) Inherits int_only
ControlInstance param(12) Inherits int_only
ControlInstance param(13) Inherits int_only
ControlInstance param(14) Inherits int_only
ControlInstance param(15) Inherits int_only
ControlInstance param(16) Inherits int_only
ControlInstance param(17) Inherits int_only
ControlInstance param(18) Inherits int_only
ControlInstance param(19) Inherits int_only
ControlInstance param(20) Inherits int_only
ControlInstance param(21) Inherits int_only
ControlInstance param(22) Inherits int_only
ControlInstance param(23) Inherits int_only
ControlInstance param(24) Inherits int_only
End Control
Control txt1 Inherits Label
ControlInstance txt1 Inherits Label
End Control
Control ver Inherits int_only
ControlInstance ver Inherits int_only
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control demo_pop Inherits PopupMenu
ControlInstance demo_pop Inherits PopupMenu
EventHandler Sub Change() set_pmx demo_pop.listindex img_reset End EventHandler
End Control
Control info Inherits Label
ControlInstance info Inherits Label
End Control
Control out Inherits Canvas
ControlInstance out Inherits Canvas
End Control
Control ska Inherits num_only
ControlInstance ska Inherits num_only
End Control
Control txt11 Inherits Label
ControlInstance txt11 Inherits Label
End Control
EventHandler Sub Open() Logo=LogoMBS(500) img_reset End EventHandler
Sub img_proc() dim b as Boolean dim i as integer info.text="running ..." time=ticks const Count = 10 for i=1 to 10 call source.ApplyMatrix(dest, 5, matrix, Displacement, ScaleFactor) next time=ticks-time out.Backdrop=dest.CopyPicture info.text=str(time/60/Count)+" sec" End Sub
Sub img_reset() Source=new PictureMBS(logo) Dest=new PictureMBS(source.Width, source.Height, source.ImageFormat) info.text="??? sec" out.Backdrop=logo End Sub
Sub init_pmx() dim x,y,cnt as integer dim txt as string dim d as Double 'read out parameters from editfields cnt=0 for y=0 to 4 for x=0 to 4 txt=trim(param(cnt).text) if txt<>"" then matrix(cnt)=val(txt) 'if not empty, get into parameter matrix else matrix(cnt)=256 'if empty, mark with 256 end if cnt=cnt+1 'next index next next Displacement=val(ver.text) 'get displacement ScaleFactor=val(ska.text) End Sub
Sub set_pmx(idx as integer) dim x as integer for x=0 to 24 param(x).text="" next ver.text="0" ska.text="1" select case idx case 0 '-----------sharp param(7).text="-1" param(11).text="-1" param(13).text="-1" param(17).text="-1" param(12).text="5" case 1 '------------------ contour param(0).text="-1" param(1).text="-2" param(2).text="-3" param(3).text="-2" param(4).text="-1" param(5).text="-2" param(6).text="2" param(7).text="5" param(8).text="2" param(9).text="-1" param(10).text="-3" param(11).text="5" param(12).text="5" param(13).text="5" param(14).text="-3" param(15).text="-2" param(16).text="2" param(17).text="5" param(18).text="2" param(19).text="-2" param(20).text="-1" param(21).text="-2" param(22).text="-3" param(23).text="-2" param(24).text="-1" case 2 '---------------------- contour 2 param(6).text="1" param(7).text="-1" param(8).text="1" param(11).text="-1" param(12).text="0" param(13).text="-1" param(16).text="1" param(17).text="-1" param(18).text="1" case 3 '----------------------- smooth param(6).text="1" param(7).text="2" param(8).text="1" param(11).text="2" param(12).text="0" param(13).text="2" param(16).text="1" param(17).text="2" param(18).text="1" ska.text="0.084" case 4 '----------------------- relieff param(6).text="-5" param(8).text="1" param(11).text="-3" param(12).text="1" param(13).text="3" param(16).text="-1" param(18).text="5" ver.text="0" ska.text="0.1" end select End Sub
Property Dest As PictureMBS
Property Displacement As Integer
Property Logo As Picture
Property Matrix(24) As Integer
Property ScaleFactor As double
Property Source As PictureMBS
Property Protected imx(4,4,2) As integer
Property Protected time As integer
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "Ablage"
MenuItem FileQuit = "Beenden"
MenuItem UntitledMenu0 = "Bearbeiten"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Ausschneiden"
MenuItem EditCopy = "Kopieren"
MenuItem EditPaste = "Einfügen"
MenuItem EditClear = "Löschen"
End MenuBar
Class int_only Inherits TextField
EventHandler Sub TextChange() dim i,e as integer dim s,c,m as string dim use as boolean if not use then use=true sel_pos=me.selstart m=one_minus(me.text) e=len(m) if e>0 then s="" for i=1 to e c=mid(m,i,1) if is_number(c) then s=s+c end if next end if me.text=s me.selstart=sel_pos use=false end if End EventHandler
Protected Function is_number(c as string) As boolean return instr("0123456789-",left(c,1))<>0 End Function
Protected Function one_minus(inp as string) As string dim m as string m=left(inp,1) return m+replaceall( right(inp,len(inp)-1),"-","" ) End Function
Property Protected sel_pos As integer
End Class
Class num_only Inherits TextField
EventHandler Sub Open() me.alignment=3 End EventHandler
EventHandler Sub TextChange() dim i,e as integer dim s,c,m as string dim use as boolean if not use then use=true sel_pos=me.selstart m=only_komma(replaceall(me.text,",",".")) e=len(m) if e>0 then s="" for i=1 to e c=mid(m,i,1) if is_number(c) then s=s+c end if next end if me.text=s me.selstart=sel_pos use=false end if End EventHandler
Protected Function is_number(c as string) As boolean return instr("0123456789.",left(c,1))<>0 End Function
Protected Function only_komma(inp as string) As string dim a,b as string if countfields(inp,".")>1 then a=nthfield(inp,".",1) if a="" then a="0" sel_pos=sel_pos+1 end if b=nthfield(inp,".",2) if b="" then b=nthfield(inp,".",3) sel_pos=sel_pos+len(b) end if return a+"."+b else return inp end if End Function
Property Protected sel_pos As integer
End Class
Class App Inherits Application
End Class
End Project

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


The biggest plugin in space...