Save QR as PNG file

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Piotr D
Posts: 137
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Save QR as PNG file

#1 Post by Piotr D »

Hi,
Alaska provides a library for printing QR codes. However, I'd like to save them as a PNG file instead of printing them. How can I do this?

Regards
Piotr

User avatar
unixkd
Posts: 634
Joined: Thu Feb 11, 2010 1:39 pm

Re: Save QR as PNG file

#2 Post by unixkd »

Try

StrFile(xvar,"abc.png")

Joe

User avatar
PedroAlex
Posts: 249
Joined: Tue Feb 09, 2010 3:06 am

Re: Save QR as PNG file

#3 Post by PedroAlex »

Piotr,
I assume you are familiar with the QR-Code capabilities of the 2d-barcode asset that you can install using the workbench.
Based on this asset you need to create a Presentation Space that you connect with a XbpBitmap object. Let the QRCode object generate the output to that Presentation Space and then use the XbpBitmap object to save the image to a file.
Please refer to the sample attached to this post.
Hope this helps.
With my best regards,
Save2File_QRCode_sample.zip
(1.03 KiB) Downloaded 13 times
Pedro Alexandre

Piotr D
Posts: 137
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: Save QR as PNG file

#4 Post by Piotr D »

Hi Pedro

many thanks for your help. I will try.

Regards
Piotr

User avatar
SlavkoDam
Posts: 158
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: Save QR as PNG file

#5 Post by SlavkoDam »

Alaska algorithm for drawing QR is very slow, because it draws every pixel with GraBox(). If you display QR on the screen, you can view drawing of each pixel. For larger QR with dimension of 400 and higher, it takes 2-3 seconds to draw.
Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

Piotr D
Posts: 137
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: Save QR as PNG file

#6 Post by Piotr D »

Hi Pedro,
your sample works fine, but if I change in:
oBmp:saveFile( "..\out.gif", XBPBMP_FORMAT_GIF )
to PNG format:
oBmp:saveFile( "..\out.gif", XBPBMP_FORMAT_PNG )

the the method returns false and file is not created. The file created with XBPBMP_FORMAT_GIF is for me enough, but creation with XBPBMP_FORMAT_PNG is not possible. Or maybe I should do something extra?

Regards
Piotr

Post Reply