QRcode ENCODE via ZXingWidget in iPhone?

2,476 views
Skip to first unread message

NotarySojac

unread,
Nov 5, 2010, 6:32:40 PM11/5/10
to zxing
Hi - ZXing folks - Evidnelty, it's quite possible to use JAVA to
ENCODE a QRcode image. The ZXingWidget 1-6 code for the iPhone works
great - but I do not see how I can ENCODE from with an app running in
the iPhone.

Am I missing something? What would you suggest as the way to ENCODE a
QRcode image on the iPhone?

Thanks!

Steven Parkes

unread,
Nov 5, 2010, 9:20:56 PM11/5/10
to zx...@googlegroups.com
> Am I missing something? What would you suggest as the way to ENCODE a
> QRcode image on the iPhone?

The Java encoder hasn't been ported to C++. It'd be nice, if you someone has the time.

I've used the psytec encoder:

http://www.koders.com/cpp/fid11B46888A4C3B56975E7C876D468BEE261A5C02B.aspx?s=dir
http://www.psytec.co.jp/docomo.html

NotarySojac

unread,
Nov 5, 2010, 11:58:45 PM11/5/10
to zxing
>The Java encoder hasn't been ported to C++. It'd be nice, if you someone has the time.

I took a look at the psytec source - it was somewhat daunting -
especially considering the comments are in Japanese.

But, a little progress has been made - there's a QRencode project
written by Kentaro Fukuchi - meant to be used as a command-line tool.

Once you get past all of the command-line preface and qualifications,
the project calls a function which accepts a string of data to encode
and an output filename. The problem with that project is that it
expects a PNG library to be available. The MacOSX PNG lib is not
available in the iOS iPhone world.

However, there is an ImageMagick project at
http://www.cloudgoessocial.net/2010/02/10/imagemagick-for-iphone-via-snowleopard/
that provides PNG lib support. As best I can tell - this lib is legal
as far as being used with an iPhone app being submitted to their
appstore.

I created a static library project - included the QRencode source -
yanked all of the command-line support out, linked in the pre-compiled
ImageMagick libQRencode.a, included the PNG.h from that project and it
all appears to compile without error. I guess the real excitement
will come when I try to use it to create a PNG file in the iPhone
device /Documents folder - which I have yet to do. I guess I'll first
try and get the simulator to behave as expected - then see if the
activity translates into the iPhone, itself. The final hurdle will be
if the folks at Apple will let all of this live in an iPhone app
offered via the appstore.

BTW - I wrote Mr. Fukuchi and asked if he had any thoughts about
moving his project over into the iPhone world - but have not heard
back, yet. Again - there's the issue of the PNG lib - mentioned in
Mr. Fukuchi's project. If and when all of this works - well, in any
case - I'll post the results.

Thanks for your response - here's hopin'!

Steven Parkes

unread,
Nov 6, 2010, 12:51:00 AM11/6/10
to zx...@googlegroups.com
> I took a look at the psytec source - it was somewhat daunting -
> especially considering the comments are in Japanese.

It's really not a big deal. You don't need to understand the comments, though it helps to know a little about QR codes, so you understand the terminology like version and masking.

The Ruby rqr gem uses the psytec code, so there's an example there (it's pretty simple; don't think you need to understand the ruby side of things).

What will work depends a little on what you want. I go from the bitmap output of the psytec class (which is also pretty similar to what the java zxing encoder generates) straight into a CoreImage buffer. I didn't want to generate an external png. Honestly, I can't imagine bringing in all of ImageMagick just for that.

NotarySojac

unread,
Nov 6, 2010, 5:59:05 PM11/6/10
to zxing
Hi Steven -

You are so right - the ImageMagick idea was (for me in this case) a
non-productive timehole - and overkill for my purposes - although
there is alot of nice stuff going on in there.

What I ended up getting to work was my stripped down version of the
QRencode project from Mr. Fukuchi linked with the lpng144 project
output from SourceForge and the ZLIB.net project binary. There is so
much great work that has been done so well by so many people - it
really gives software developers a huge leg-up versus having to re-
invent everything from scratch.

Thanks very much for your assistance and good info - in the words of a
recent high government official, "Mission Accomplished!"
Message has been deleted

Spokane-Dude

unread,
May 25, 2011, 2:31:17 PM5/25/11
to zx...@googlegroups.com
Is it possible you can post your "stripped down version of the QR Encode project from Mr. Fukuchi?  There are a lot of developers who would really appreciate it! :D

NotarySojac

unread,
Jun 2, 2011, 3:34:11 PM6/2/11
to zxing
Hi ZXing folks -

I am not a lawyer and don't want to violate Mr. Fukuchi's rights -
but, if - in reality - it's OK to do so, I'd be happy to share. The
project builds a static QRcode library which then needs to be linked
with libpng.a plus whatever you have that might be calling into those
libs. So the QRcode peoject is just one piece of the requisite larger
puzzle needed to be solved. Also, I'm not sure what's the best way/
place to post my QRcode project - would somebody please suggest a good
way?

One thing I found was that the size of the created PNG file was
hardwired in the QRcode lib - obviously not an optimal situation.

For sure, there's more to working with QRcode recognition and/or
creation that just getting the QRcode lib to build.

Just as a comment - my experience with using the ZXing and QRcodes in
both iOS and MacOS have been excellent. I've done some work in
creating a MacOS Cocoa ZXing demo app - with the help of wonderfully
knowledgeable folks in the ZXing community - and we're working on
getting this extension made available here. Well, as they used to say
on the 6 o'clock news, "Film at 11".

Thanks!

Spokane-Dude

unread,
Jun 2, 2011, 3:42:14 PM6/2/11
to zx...@googlegroups.com
I am not a lawyer either, but I don't believe there are any restrictions on Fukuchi-san's code... it's everywhere.  So, I for one would really appreciate looking at your code, since I'm struggling with my own, specifically how to generate the image of the QRCode object.

Regards...

Steven Parkes

unread,
Jun 2, 2011, 3:56:45 PM6/2/11
to zx...@googlegroups.com
> I am not a lawyer either, but I don't believe there are any restrictions on Fukuchi-san's code

It's very clearly LGPL'd.

This has been discussed before: http://groups.google.com/group/zxing/browse_thread/thread/43d1dabd80ede840/1b3d58daf6289d45?#1b3d58daf6289d45

See also http://stackoverflow.com/questions/459833/which-open-source-licenses-are-compatible-with-the-iphone-and-app-store

NotarySojac

unread,
Jun 2, 2011, 4:14:34 PM6/2/11
to zxing
> It's very clearly LGPL'd.

That is fantastic - as a relatively new member of the open-source
community, my wish was to not get in everyone's bad graces by
distributing material in a manner that the authors would wish was not
the case. It was my understanding that it was OK to acquire, modify
and use the code as part of my project - but I was not sure about re-
distributing the work - to others - with my changes.

Spokane-Dude

unread,
Jun 2, 2011, 4:15:17 PM6/2/11
to zx...@googlegroups.com
So Steve, putting that in language that a "normal, reasonable" person would understand:  it's ok to use Fukuchi-san's code in an iPhone app as long as you provide .o files that someone could link to?  Which makes no sense to me what-so-ever, but as long as I don't have to release my source, I'm cool with the .o files.

Or am I completely out-of-the-ballpark?

NotarySojac

unread,
Jun 2, 2011, 4:16:31 PM6/2/11
to zxing

So does anyone have a preference as where's a good place to deposit
the zip-wrapped Xcode4 project?

Spokane-Dude

unread,
Jun 2, 2011, 4:18:14 PM6/2/11
to zx...@googlegroups.com
I use DropBox...it's free...  you could also try GitHub, but I haven't used it except for downloading...

Steven Parkes

unread,
Jun 2, 2011, 4:24:05 PM6/2/11
to zx...@googlegroups.com
Everything necessary to do the final link: the .o', the project files, any assets/resources, etc. Basically everything such that an existing .a or .o representing the LGPL'd code could be switched and then the final executable recreated.

Note that this is still questionably legit, since you have to be a paid Apple developer to create a signed app that you can run on a device. It's been questioned whether this is acceptable under the LGPL.

Note that I've never heard of anyone pursuing enforcement of this. But that's why I use the psytec encoder instead. Just avoids the issue completely. I don't use any LGPL code in iOS apps.

Steven Parkes

unread,
Jun 2, 2011, 5:27:06 PM6/2/11
to Rolf Marsh, zx...@googlegroups.com
Offered without guarantees or support:

https://gist.github.com/1005365

On Jun 2, 2011, at 2:11 PM, Rolf Marsh wrote:

> Thanks for the clarification Steven... you don't happen to have some English docs that would give me (and others) a cookbook approach to using Psytec Encoder, do you? I translated the webpage, but it's not much help... I just want to take a the QR object (from QREncoder) and display it in a UIImageView.

Spokane-Dude

unread,
Jun 2, 2011, 5:30:20 PM6/2/11
to zx...@googlegroups.com, Rolf Marsh
YOU ARE "THE MAN"!  Thank you so much... you don't know how much time this is going to save me.  I truly appreciate it!

Warm Regards,
Spokane-Dude

NotarySojac

unread,
Jun 2, 2011, 6:06:36 PM6/2/11
to zxing
OK - here's an SSH link to the pushed QRencodeMac project I have
placed on GitHub

g...@github.com:notarysojac/QRencodeMac.git

Here's hoping this helps you - it sure works well for me in my iOS app
in which I have the ZXingWidget also embedded.

The next question which seems to come up when dealing with this corner
of the code-world is, "OK, I have a PNG file from this lib - now how
do I print it from my iOS device?" I got this path to work by
creating a Bonjour connection from my WiFi Airport Extreme - and use
my shared printer via my desktop system. If you so desire, the code
can, alternately, place your PNG image in the place that uploads
images from your iOS device into <iPhoto> when your device is
connected to your host computer - where you can then print it at such
time or in whatever way is convenient.

For code snips which may help you get those chores accomplished, you
can snag this bag-o-code-snips at:

g...@github.com:notarysojac/iOS_QRcode_PNG_Print_Snips.git

Have fun - I sure hope this saves you some time - if what you find
looks like a rat-hole to you - don't go there - the intent is to make
things nicer - not more frustrating.

madik

unread,
Jun 10, 2011, 6:46:13 AM6/10/11
to zxing
Hi!

I really need for this solution, but I don't really understand, how
can I call the encoder from my objective c code. Which method I have
to call and how? Till this time, I try to use this encoder:
https://github.com/jverkoey/ObjQREncoder#readme

The problem with this, there is a limit, how many characters can be
encoded (on high correction level, only 35 characters, on low
correction level I don't know the exact number, but the image will be
very blurred).
NotarySojac! I really appreciate your help! Thanks...
Reply all
Reply to author
Forward
0 new messages