; Module/File: Gadget_QrDecode.pb ; Function: Read a QrCode png-file and show the content (needs zbarimg) - Linux ; Author: Omi ; Date: May. 16, 2015 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.4x ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- ;'Gadget_QrGenerator.pb' has to be run first to get the example-qrcode-code in '/tmp/tmp.png'! Global.s gQrFile Procedure.s QrContent(QrCodeFile.s) Protected.i PBImage, QrEncodeID Protected.i zBarImgExists= RunProgram ("which", "zbarimg", "", #PB_Program_Open | #PB_Program_Read) Protected.s PrgOutput If zBarImgExists While ProgramRunning(zBarImgExists) If AvailableProgramOutput(zBarImgExists) PrgOutput+ ReadProgramString(zBarImgExists) + #LF$ EndIf Wend If PrgOutput = "" MessageRequester("", "'zbarimg' not found!" + #LF$ + "Use e.g. 'sudo apt-get install zbar-tools'.") ProcedureReturn "" EndIf PrgOutput = "" QrEncodeID= RunProgram ("zbarimg", QrCodeFile, GetTemporaryDirectory(), #PB_Program_Open | #PB_Program_Read | #PB_Program_Error) If QrEncodeID While ProgramRunning(QrEncodeID) If AvailableProgramOutput(QrEncodeID) PrgOutput+ ReadProgramString(QrEncodeID) + #LF$ EndIf Wend If ProgramExitCode(QrEncodeID) Debug ReadProgramError(QrEncodeID) EndIf EndIf Else MessageRequester("", "'zbarimg' not found!" + #LF$ + "Use e.g. 'sudo apt-get install zbar-tools'.") EndIf ProcedureReturn PrgOutput EndProcedure If OpenWindow(0, 0, 0, 300, 128, "QRCode example (Linux)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) gQrFile= "/tmp/tmp.png" TextGadget(#PB_Any, 5, 5, 290, 22, "Message in image at " + gQrFile) TextGadget(#PB_Any, 5, 30, 290, 22, QrContent(gQrFile)) Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf ; IDE Options = PureBasic 5.45 LTS (Linux - x86) ; CursorPosition = 3 ; Folding = - ; EnableUnicode ; EnableXP