Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CoreImage/Simple Filter with Picture
Function:
Required plugins for this example: MBS MacCG Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreImage/Simple Filter with Picture
This example is the version from Thu, 6th Apr 2016.
Project "Simple Filter with Picture.rbp"
Class Window1 Inherits Window
Control Slider1 Inherits Slider
ControlInstance Slider1 Inherits Slider
EventHandler Sub ValueChanged() if me.Enabled then Canvas1.Invalidate end if End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) dim result as CIImageMBS dim time as integer time=ticks cifilter.inputBrightness=Slider1.Value/100.0 result=cifilter.outputImage g.DrawPicture result.RenderPicture, 0, 0 System.DebugLog "Paint needed "+str((ticks-time)/60.0)+" seconds." End EventHandler
End Control
EventHandler Sub Open() dim n as CIAttributeMBS dim file as FolderItem dim ciimage as CIImageMBS cifilter=new CIFilterColorControlsMBS n=CIFilter.AttributeinputBrightness if n<>Nil then Slider1.Minimum=n.SliderMinNumber*100 Slider1.Maximum=n.SliderMaxNumber*100 slider1.Value=n.DefaultNumber*100 Slider1.Enabled=true file=FindFile("juz.jpg") ciimage=NewCIImagewithFileMBS(file) if ciimage<>nil then // Fails always on Mac OS X 10.3... // Make Filter CIFilter.inputImage=CIImage end if else MsgBox "Missing CoreImage filter ""ColorControls""?" end if Width=juz.Width Height=juz.Height End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Property Protected CIFilter As CIFilterColorControlsMBS
Property Protected count As integer
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() if TargetMachO then else MsgBox "This project needs a MachO target." end if End EventHandler
End Class
ExternalFile juz
End ExternalFile
End Project

See also:

Feedback, Comments & Corrections

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





Links
MBS Xojo Plugins