Files
playlet-piped/playlet-lib/src/components/QrCodePoster/GenerateQrCodeJob.bs
T
Brahim Hadriche 82dea9af37 Remove asynctask code (#666)
* Remove asynctask code

* add job test example

* Fix testing

* Fix a couple of imports
2025-06-22 17:39:58 -04:00

39 lines
762 B
Plaintext

import "pkg:/source/QrCode/QrImage.bs"
import "pkg:/source/QrCode/QrMode.bs"
import "pkg:/source/utils/StringUtils.bs"
@job("GenerateQrCodeJob")
function ExecuteJob() as void
input = JobGetInput()
poster = input.poster
mode = input.mode
text = input.text
size = input.size
padding = input.padding
if mode = invalid
mode = QrCode.QRMode.Byte
end if
if size = invalid
size = 200
end if
if padding = invalid
padding = 0
end if
qr = new QrCode.QRImage()
imagePath = qr.Generate(text, size, padding, mode)
if JobIsCancelled()
JobCancel()
return
end if
if not StringUtils.IsNullOrEmpty(imagePath)
poster.uri = imagePath
end if
end function