Page 1 of 1

Creating a QR code to display an image

Posted: Wed Feb 24, 2021 5:02 pm
by glenn9
Hi Everyone,

I'm currently learning how to use QR codes with LC and have so far successfully done this with the Squirt library (http://forums.livecode.com/viewtopic.php?t=31434.

This works absolutely fine with text but I was wondering if I could generate a QR code for an image stored in the stack (as opposed to externally)

I therefore put together this code:

Code: Select all

on mouseup
   put 1 into field 1
   put image"Im" into tIm
   set the imagesource of char 1 of field "txtFIELD" to "Im"  #(thank you Klaus!)
   
   put field 1 into tQRData
   qrCreate "!", tQRData, "M", 3 
   put the result into tImagedata
   delete line 1 of tImagedata
   put tImagedata into img 1
end mouseup
which compiles successfully but returns '1', ie the original char that was originally set by 'imagesource' but not the image itsself!

I guess a workaround would be to have the QR link to an external file on for example dropbox, but I was really wanting it to have generated the QR code from the image stored in the stack.

This might not be possible of course?

Re: Creating a QR code to display an image

Posted: Wed Feb 24, 2021 5:12 pm
by glenn9
apologies if this has caused confusion but field 1 and field"txtFIELD' are both the same field!

Re: Creating a QR code to display an image

Posted: Wed Feb 24, 2021 9:20 pm
by liveme
Hi Glenn
(interested)
can any of these QR result be put into an "image field" or "text field" instead of a variable ?
What would it look like ?

Re: Creating a QR code to display an image

Posted: Thu Feb 25, 2021 9:48 am
by glenn9
Hi Liveme,

The original image is in an image field and I originally tried to do something like this

Code: Select all

...put field 1 into tQRData
qrCreate "!", tQRData, "M", 3...
   
but it didn't seem to compile, ie with no success.

Regards,

Glenn

Re: Creating a QR code to display an image

Posted: Thu Feb 25, 2021 10:07 am
by Klaus
AHA! Now I get it!
No, sorry, this is not possible, you need to provide a "real" image object.

To avoid confusion:
Please use
-> image object
and
-> text field

There is no image field in LC. :D

Re: Creating a QR code to display an image

Posted: Thu Feb 25, 2021 12:45 pm
by liveme
The original image is in an image field
I beleive livecode can deal with images of type SVG.
so if you start with an SVG type image - stored into your App.
Vectors are just a bunch of strings,
you can store them in a variable and play with those to a certain extend.
I'm not sure what process you plan on applying to this image though.

Re: Creating a QR code to display an image

Posted: Fri Feb 26, 2021 12:08 pm
by Xero
Do you wish to encode the imagedata of an image into a QR code? That would be a lot of data unless the image is quite small. QR codes are generally used for small amounts of data. The module (177x177) will encode 7089 numbers, 4296 alphanumeric.
It almost sounds like you want to have a QR code that references an image within your stack. Do you want to scan the QR and do something within your stack? i.e. the data within the QR code would be something like "set the location of image "face" to 50,50". That way, when you scan the QR, that line of code is called up and used to move an image on screen. That's essentially what QR codes often do. You scan it and it sends you to a website for example. It doesn't encode the website. Just opens a browser and goes to an address.
XdM

Re: Creating a QR code to display an image

Posted: Fri Feb 26, 2021 12:45 pm
by glenn9
Many thanks for your reply, initially I had thought that I might be able to encode the imagedata of an image into a QR code but I do see now the limitations and the intended role of QR codes.

Now have a better understanding - thank you.

Regards,

Glenn

Re: Creating a QR code to display an image

Posted: Tue Mar 02, 2021 7:02 am
by liveme
Glenn, you could convert a 64 text string to an image (jpeg) using some Basecode64 feature,
*or the other way arround.
if that serves :| :arrow: