Skip to content

Commit

Permalink
Issue VFPX#5 Work In Progress: Add icon to QR size
Browse files Browse the repository at this point in the history
Changes:
- Added function to calculate logo size
- Added Function to calculate logo position
- Upgrade the FoxBarcodeQR form

ToDo:
- use some libreary i.e. GDIPlusX to render the image on existing QR code

Signed-off-by: Piotr Poniewicz <[email protected]>
  • Loading branch information
ZuchBoy committed Nov 30, 2022
1 parent 8015187 commit 342c58c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
Binary file modified FoxBarcodeQR_v_2_10/FoxBarcodeQR.pjt
Binary file not shown.
Binary file modified FoxBarcodeQR_v_2_10/foxbarcodeqr.SCT
Binary file not shown.
Binary file modified FoxBarcodeQR_v_2_10/foxbarcodeqr.pjx
Binary file not shown.
38 changes: 38 additions & 0 deletions FoxBarcodeQR_v_2_10/foxbarcodeqr.prg
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,44 @@ DEFINE CLASS FoxBarcodeQR AS CUSTOM
"Line: " + TRANSFORM(m.nLine)
MESSAGEBOX(m.lcErrMsg, 0 + 16, "FoxBarcodeQR error")
ENDPROC

*---------------------------------------------------------
* Function CalculateLogoSize(nQrSize)
*---------------------------------------------------------
* Params:
* nQrSize = size of the side length (in pixels)
* Returns the optimal size of logo which we can add
*---------------------------------------------------------
FUNCTION CalculateLogoSize
LPARAMETERS nQrSize
IF TYPE("nQrSize") <> 'N'
RETURN
ENDIF
LOCAL lnLogoSize, lnImageRatio
lnImageRatio = 2.75
lnLogoSize = ROUND(nQrSize / lnImageRatio, 0)
RETURN lnLogoSize
ENDFUNC

*---------------------------------------------------------
* Function SetLogoPosition(nQrSize)
*---------------------------------------------------------
* Params:
* nQrSize = size of the side length (in pixels)
* nLogoSize = calculated size of logo (output from CalculateLogoSize)
* Returns the begin position of drawing logo
*---------------------------------------------------------
FUNCTION SetLogoPosition
LPARAMETERS nQrSize, nLogoSize
IF TYPE("nQrSize") <> 'N'
RETURN
ENDIF

LOCAL lnCentralPosition, lnPixelDrawPosition
lnCentralPosition = nQrSize / 2
lnPixelDrawPosition = ROUND(lnCentralPosition - (nLogoSize / 2),0)
RETURN lnPixelDrawPosition
ENDFUNC

ENDDEFINE && FoxBarcodeQR

Expand Down
Binary file modified FoxBarcodeQR_v_2_10/foxbarcodeqr.scx
Binary file not shown.

0 comments on commit 342c58c

Please sign in to comment.