PC SOFT
ONLINE REPOSITORY
FOR WINDEVWEBDEV AND WINDEV MOBILE

Home |  | Sign in | English US
Gerar QRCODE, Interpretar a Imagem do QRCODE EM MOBILE
Published by Boller
in the category Tools
New features



Description
Exemplo permite gerar um QRCODE colocando as informações criptografadas e lendo o arquivo bmp gerado e interpretar o conteudo usando os comandos nativos da função WLanguage.

//PARA GERAR QRCODE
IF CBOX_Criptografar = True THEN
BAC_Qrcode = Encode(EDT_Valor,encodeBASE64)
ELSE
BAC_Qrcode = EDT_Valor
END

dSaveImageBMP(BAC_Qrcode,fCurrentDir()+fSep()+"QrcodeImagem.bmp")

IF fFileExist(fCurrentDir()+fSep()+"QrcodeImagem.bmp") = True THEN
Info("Arquivo gerado com sucesso")
END

//----------------------------------------------------------------------------------------------------------------------------

//LER QRCODE
EDT_Img = fSelect("", "", "Select a file...", "All the files (*.*)" + TAB + "*.*", "*.*")

IMG_Qrcode = dLoadImage(EDT_Img,imgDefault)

//---------------------------------------------------------------------------------------------------------------------------

// Decode a QR Code from a Camera control
s is Buffer
s = dSaveImageBMP(IMG_Qrcode, inMemory)
bc is BarCode
bc = BCDecode(s)
valor is string

IF CBOX_Descipt = True
valor = Decode( bc.Content ,encodeBASE64)
ELSE
valor = bc.Content
END

Info(valor)

//-------------------------------------------------------------------------------------------------------------------------------------------------------

// Abrir a galeria para selecionar o QR-Code
// OPEN THE GALLERY TO PICK THE IMAGE (QR-CODE)
QRCode is string = AlbumPicker(albumImage)

//Verificar se o caminho da imagem está vazio
// CHECK IF THE PATH/IMAGE IS EMPTY
IF QRCode = "" THEN
ToastDisplay("Ocorreu um erro ao selecionar a imagem!", toastLong,vaMiddle,haCenter)
RETURN
END


// Decode a QR Code from a Image
// DECODE QR-CODE INTO A BUFFER
ImagemCarregada is Buffer

ImagemCarregada = dLoadImage(QRCode)
IMG_test=ImagemCarregada // SHOW ON THE SCREEN THE RESULT OF dLoadImage

s is Buffer
s = dSaveImagePNG(IMG_test, inMemory)

bc is BarCode
bc = BCDecode(s)

//bc is BarCode
//bc = BCDecode(ImagemCarregada)

IF ErrorOccurred() = True THEN
Info(ErrorInfo(errMessage+Charact(13)+errFullDetails))
END

//Verificar se a imagem selecionada é um QR-Code
// CHECK THE BARCODE TYPE
IF bc..TypeBarCode <> BC_QRCODE THEN
ToastDisplay("A imagem não tem o formato de um QR-code", toastLong,vaMiddle,haCenter)
RETURN
END

//Verificar se o conteúdo do QR-Code está vazio
// CHECK IF THE DECODED CONTENT IS EMPTY
IF bc..Content = "" THEN
ToastDisplay("QR-Code sem conteúdo!", toastLong,vaMiddle,haCenter)
RETURN
END

gsQRconteudo is string = ""
gsQRconteudo = bc.Content

TamanhoString is int = Length(gsQRconteudo)

EDT_NoName1=gsQRconteudo // SHOW THE RESULT ON THE RESPECTIVE FIELD

//---------------------------------------------------------
Ajuda feita pelo programador "José Willem"
PodCast do Amarildo 14/01/2023
//---------------------------------------------------------
Illustrations, screen shots
none
none
User reviews
(To evaluate this resource, click 'Write a review')
Boller
Exemplo criado para atender o programador Joao Ferreira