Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Picture/Picture Hash/Picture Hash
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Picture/Picture Hash/Picture Hash
This example is the version from Thu, 18th Apr 2018.
Project "Picture Hash.rbp"
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 CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean if column = 0 and row < me.ListCount then dim p as Picture = me.RowTag(row) if p <> nil then g.DrawPicture p, 0, 0 end if end if End EventHandler
End Control
EventHandler Sub Open() SplitCards 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
Sub SplitCards() dim f as FolderItem = FindFile("Cards.png") if f = nil then MsgBox "Cards not found!" return end if dim p as Picture = Picture.Open(f) dim n as integer = 0 for y as integer = 0 to 6 for x as integer = 0 to 7 dim pic as new Picture(50, 70) pic.Graphics.DrawPicture p, 0, 0, pic.Width, pic.Height, x*49, y*69, pic.Width, pic.Height pictures.Append pic n = n + 1 if n = 52 then exit end if next next for each pp as Picture in pictures list.AddRow "", hex(pp.HashMBS) list.RowTag(List.LastIndex) = pp next End Sub
Property Pictures() As Picture
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
End Project

See also:

Feedback, Comments & Corrections

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





Links
MBS FileMaker blog