PowerBuilder Requires Chilkat v11.7.0+
PowerBuilder
QR Code Quiet Zone, Padding and Rotation
See more QR Code Examples
Demonstrates the space around a QR code and its rotation. The quiet zone is the blank margin a reader needs around the symbol. It is measured in modules, the QR standard requires 4, and QrCode will make it larger but not smaller. Padding is extra space outside the quiet zone, measured in the render units (pixels by default). Rotation turns the whole image by 90, 180 or 270 degrees. A QR code reads the same at any rotation.Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Json
oleobject loo_Fmt
oleobject loo_JsonOut
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
destroy loo_Json
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Json.UpdateString("payload.text","https://www.chilkatsoft.com/")
loo_Json.UpdateInt("render.moduleSize",6)
// A quiet zone of 6 modules on every side instead of the standard 4.
loo_Json.UpdateInt("render.quietZone.left",6)
loo_Json.UpdateInt("render.quietZone.top",6)
loo_Json.UpdateInt("render.quietZone.right",6)
loo_Json.UpdateInt("render.quietZone.bottom",6)
// 10 more pixels of background around that.
loo_Json.UpdateInt("render.padding",10)
// Turn the image a quarter turn clockwise.
loo_Json.UpdateInt("render.rotation",90)
loo_Json.UpdateString("output.path","qa_output/qr_margins.png")
loo_Json.UpdateBool("output.overwrite",1)
loo_Json.UpdateString("output.return","none")
loo_Fmt = create oleobject
li_rc = loo_Fmt.ConnectToNewObject("Chilkat.Formats")
loo_JsonOut = create oleobject
li_rc = loo_JsonOut.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_Fmt.QrCode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut
return
end if
Write-Debug "module: " + string(loo_JsonOut.IntOf("measurements[0].pitch")) + " pixels"
Write-Debug "symbol: " + string(loo_JsonOut.IntOf("measurements[0].symbolWidth")) + " x " + string(loo_JsonOut.IntOf("measurements[0].symbolHeight")) + " pixels at (" + string(loo_JsonOut.IntOf("measurements[0].symbolX")) + "," + string(loo_JsonOut.IntOf("measurements[0].symbolY")) + ")"
Write-Debug "quiet zone: " + string(loo_JsonOut.IntOf("measurements[0].quietZonePx.left")) + " pixels"
Write-Debug "padding: " + string(loo_JsonOut.IntOf("measurements[0].paddingPx")) + " pixels"
Write-Debug "rotation: " + string(loo_JsonOut.IntOf("measurements[0].rotation"))
Write-Debug "image: " + string(loo_JsonOut.IntOf("measurements[0].canvasWidth")) + " x " + string(loo_JsonOut.IntOf("measurements[0].canvasHeight")) + " pixels"
// The image, enlarged, with the quiet zone and the padding tinted here to show where they are.
// In the image itself both are plain white. A QR code has no finder pattern (the large squares)
// in its bottom right corner. After the quarter turn that corner is at the bottom left:
//
// Sample output:
// module: 6 pixels
// symbol: 174 x 174 pixels at (46,46)
// quiet zone: 36 pixels
// padding: 10 pixels
// rotation: 90
// image: 266 x 266 pixels
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut