Platforms to show: All Mac Windows Linux Cross-Platform
/MacCG/CoreGraphics DirectDisplay/CGDisplayStreamEvent test
Required plugins for this example: MBS MacCG Plugin, MBS Main Plugin, MBS MacCI Plugin, MBS MacCF Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics DirectDisplay/CGDisplayStreamEvent test
This example is the version from Tue, 26th Sep 2016.
Project "CGDisplayStreamEvent test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control output Inherits Canvas
ControlInstance output Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect)
if pic <> nil then
g.DrawPicture pic, 0, 0
if RefreshedRects <> nil then
g.ForeColor = &cFF0000
for each r as CGRectMBS in RefreshedRects
g.DrawRect r.Left, r.top, r.Width, r.Height
next
end if
end if
End EventHandler
End Control
EventHandler Sub Open()
dim c as CGDisplayMBS = CGDisplayMBS.MainDisplay
m = new MyCGDisplayStreamEvent(c.Handle, 500, 366 )
m.list = list
m.output = output
m.factor = 500.0 / c.Bounds.Width
m.Start
End EventHandler
Property RefreshedRects() As CGRectMBS
Property m As MyCGDisplayStreamEvent
Property pic As Picture
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyCGDisplayStreamEvent Inherits CGDisplayStreamEventMBS
EventHandler Sub FrameAvailable(Status as Integer, displayTime as UInt64, frameSurfaceHandle as Integer, Update as CGDisplayStreamUpdateMBS)
dim n as integer = 0
dim statustext as string
Select case status
case StatusFrameBlank
statustext = "Blank"
case StatusFrameComplete
statustext = "Complete"
case StatusFrameIdle
statustext = "Idle"
case StatusStopped
statustext = "Stopped"
else
Break
end Select
// filter our own window.
dim RefreshedRects() as CGRectMBS = update.getRects(update.UpdateRefreshedRects)
dim MovedRects() as CGRectMBS = update.getRects(update.UpdateMovedRects)
// show others, e.g. seconds in menubar
list.InsertRow n, "FrameAvailable at "+str(displayTime)+": "+statustext+", "+str(update.DropCount)+" drops"
for each r as CGRectMBS in RefreshedRects
n = n + 1
list.InsertRow n, " refreshed: pos: "+str(r.Left)+"/"+str(r.top)+", width: "+str(r.Width)+", height: "+str(r.Height)
next
for each r as CGRectMBS in MovedRects
n = n + 1
list.InsertRow n, " moved: pos: "+str(r.Left)+"/"+str(r.top)+", width: "+str(r.Width)+", height: "+str(r.Height)
next
dim ci as CIImageMBS = Update.CIImage
if ci <> nil then
dim p as Picture = ci.RenderPicture
if p <> nil then
MainWindow.RefreshedRects = RefreshedRects
MainWindow.pic = p
output.Invalidate
end if
end if
End EventHandler
Property factor As Double
Property list As Listbox
Property output As canvas
End Class
End Project
See also:
- /MacCG/CoreGraphics DirectDisplay/Capture Screen with CGContextMBS
- /MacCG/CoreGraphics DirectDisplay/CGDisplayReconfigurationEventMBS test
- /MacCG/CoreGraphics DirectDisplay/CGScreenRefreshEvent Test
- /MacCG/CoreGraphics DirectDisplay/Gamma Test
- /MacCG/CoreGraphics PDF/Getpicture PDF
- /MacCG/CoreGraphics PDF/PDF properties
- /MacCG/CoreGraphics PDF/PDF Text
- /MacCG/CoreGraphics PDF/PDF using Save and Restore
- /MacCG/CoreGraphics PDF/PDF with paths and gradient
- /MacCG/CoreGraphics PDF/Show PDF
The items on this page are in the following plugins: MBS MacCG Plugin.