Example: /MacCG/CGImageSource/CGImageSource Thumbnails Threaded

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CGImageSource/CGImageSource Thumbnails Threaded


Required plugins for this example: MBS MacCG Plugin, MBS MacCF Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CGImageSource/CGImageSource Thumbnails Threaded

This example is the version from Sat, 8th Feb 2019.

Project "CGImageSource Thumbnails Threaded.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean if column = 0 then dim Pic as picture = me.CellTag(row, column) if pic <> nil then dim faktor as Double = min( g.Height / Pic.Height, g.Width / Pic.Width) // Calculate new size dim w as Integer = Pic.Width * faktor dim h as Integer = Pic.Height * faktor dim xx as integer = (g.Width - w) / 2 dim yy as integer = (g.Height - h) / 2 g.DrawPicture Pic, xx, yy, w, h, 0, 0, pic.Width, pic.Height end if end if End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() // have newer images? for i as integer = list.ListCount to thread.Images.Ubound dim file as folderitem = thread.files(i) dim image as CGImageMBS = thread.Images(i) dim pic as Picture = image.Picture List.AddRow " ", file.DisplayName+EndOfLine+str(file.Length/1024,"0")+" KB" list.Celltag(List.LastIndex, 0) = pic next if thread.done then me.Mode = timer.ModeOff thread = nil end if End EventHandler
End Control
EventHandler Sub Open() dim f as FolderItem = GetFolderItem("Test Files") if not f.Exists then break // no test files? return end if thread = new MyThread thread.folder = f thread.run End EventHandler
Property thread As MyThread
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyThread Inherits Thread
EventHandler Sub Run() dim c as integer = folder.count dim options as new Dictionary options.Value(CGImageSourceMBS.kCGImageSourceThumbnailMaxPixelSize) = 100 options.Value(CGImageSourceMBS.kCGImageSourceCreateThumbnailFromImageIfAbsent) = true for i as integer = 1 to c dim file as FolderItem = folder.TrueItem(i) if file <> nil and file.Visible then dim image as CGImageMBS = CGImageSourceMBS.CreateThumbnailMT(file, 0, options) if image <> nil then images.Append image files.append file end if end if next done = true End EventHandler
Property Images() As CGImageMBS
Property done As Boolean
Property files() As FolderItem
Property folder As FolderItem
End Class
End Project

See also:

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


💬 Ask a question or report a problem