JavaScript encoding

I have some arbitrary pixel data that I want to save as PNG. How can I encode PNG using JavaScript to accomplish this?

The data is a series of 1 and 0 that I want to use to create a QR code. This is a QR code of arbitrary data.

I do not use the DOM, so jQuery and createElement are missing.

+8
javascript encoding png appcelerator titanium-mobile
source share
4 answers

If you understand correctly, you can use this library to generate qrcodes:

http://www.onlineqrlab.com/js_doc.php

Not tried, but it's well documented

+1
source share

EDIT: As with other answers, as well as links to an explanation of PNG javascript there. Hooray!

If you want to create a PNG image file, your question basically asks the question: β€œWhat is the file format for PNG? And how to convert the QR code grid to an image that is a QR code image, given that I can define this QR code using a sequence of 1s and 0s. "

You will need to consider LZW compression if you want to use PNG. Why not look at uncompressed GIFs or bitmaps? Use Titanium to create the file, hard code for the header for your image format, and then use the appropriate encoding to programmatically create your image.

But if you just want to display the QR code on the screen, why not use the Titanium Webview canvas? Or, if you are worried that it is too slow (it is not intended for draft boxes), use titanium + plus Paint for iOS.

A 'hack' may be to use absolute positioning user interface elements to create your QR code image by drawing it with user interface elements. Cool hack.

Or you can just use the SVG format in web browsing. Personally, I believe that the easiest if you need a file is to use a bitmap with a hard-coded header, as I said above, or GIF if you cannot use a bitmap.

If you just need an image, I will try to use one of the Appcelerator drawing methods.

Good luck

0
source share

Or just encode it directly into PNG with pure javascript (no need for canvas):

https://github.com/IjzerenHein/pnglib-es6

0
source share

All Articles