Creating a QR code to display an image

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Creating a QR code to display an image

Post by glenn9 » Wed Feb 24, 2021 5:02 pm

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?

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Creating a QR code to display an image

Post by glenn9 » Wed Feb 24, 2021 5:12 pm

apologies if this has caused confusion but field 1 and field"txtFIELD' are both the same field!

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Re: Creating a QR code to display an image

Post by liveme » Wed Feb 24, 2021 9:20 pm

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 ?

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Creating a QR code to display an image

Post by glenn9 » Thu Feb 25, 2021 9:48 am

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

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Creating a QR code to display an image

Post by Klaus » Thu Feb 25, 2021 10:07 am

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

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Re: Creating a QR code to display an image

Post by liveme » Thu Feb 25, 2021 12:45 pm

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.

Xero
Posts: 157
Joined: Sat Jun 23, 2018 2:22 pm

Re: Creating a QR code to display an image

Post by Xero » Fri Feb 26, 2021 12:08 pm

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

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Creating a QR code to display an image

Post by glenn9 » Fri Feb 26, 2021 12:45 pm

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

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

Re: Creating a QR code to display an image

Post by liveme » Tue Mar 02, 2021 7:02 am

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:

Post Reply