Platforms to show: All Mac Windows Linux Cross-Platform

/Barcode/zxing/Test folder


Required plugins for this example: MBS Barcode Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Barcode/zxing/Test folder

This example is the version from Fri, 27th Jun 2013.

Project "Test folder.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run() dim f as FolderItem = SpecialFolder.Desktop.Child("blackbox") dir f End EventHandler
End Control
Control Info Inherits Label
ControlInstance Info Inherits Label
End Control
EventHandler Sub Open() // download folder at dim f as FolderItem = SpecialFolder.Desktop.Child("blackbox") if f.Exists = false then MsgBox "Please download archive from http://zxing.googlecode.com/files/ZXing-2.1-testdata.zip and put blackbox folder on desktop." Return end if Thread1.run End EventHandler
Sub Dir(f as FolderItem) dim c as integer = f.Count for i as integer = 1 to c dim g as FolderItem = f.TrueItem(i) if g<>Nil then if g.Directory then dir g else dim r4 as string = g.name.Right(4) Select case r4 case ".jpg" dim t as FolderItem = g.parent.Child( Replace(g.name, ".jpg", ".txt")) test g, t case ".gif" dim t as FolderItem = g.parent.Child( Replace(g.name, ".gif", ".txt")) test g, t case ".png" dim t as FolderItem = g.parent.Child( Replace(g.name, ".png", ".txt")) test g, t end Select end if end if next End Sub
Sub Test(f as FolderItem, t as FolderItem) #pragma BreakOnExceptions false dim name as string = f.parent.name+"/"+f.name dim line as string dim FailedToReadFile,NoTextFile as Boolean // read text file if t.Exists then try dim tt as TextInputStream = TextInputStream.Open(t) tt.Encoding = encodings.UTF8 line = tt.ReadLine catch io as IOException FailedToReadFile = True end try else NoTextFile = true end if // get picture dim p as Picture = Picture.Open(f) // read image try dim b as zxingBinaryBitmapMBS = zxingBinaryBitmapMBS.CreateWithPicture(p) // zxing reader dim x as new zxingMultiFormatReaderMBS dim d as new zxingDecodeHintsMBS(zxingDecodeHintsMBS.DefaultHint) d.TryHarder = true x.setHints(d) dim result as zxingResultMBS = x.decode(b) dim bf as zxingBarcodeFormatMBS = result.BarcodeFormat // show result dim r as string = result.text if FailedToReadFile then list.AddRow name, line, r, "Failed to read text file" elseif NoTextFile then list.AddRow name, line, r, "" else dim re as string = "failed" if r = line then re = "okay" end if list.AddRow name, line, r, re end if catch re as zxingExceptionMBS list.AddRow name, line, "", "failed to decode image" end try End Sub
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
End Project

See also:

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


The biggest plugin in space...