-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How pass blob imageData rather than Url #227
Comments
I have a similar problem, it would be good if you could use jsQR to read the content of a QR code.
|
To pass the canvas data to the jsQR function, you can use the getImageData method of the canvas context to retrieve an ImageData object, which represents the pixel data for the canvas. You can then pass the data property of the ImageData object, along with the width and height of the canvas, to the jsQR function. Here's an example of how you can do this:
This code creates a canvas element, loads an image from the specified url, and then draws the image onto the canvas. It then retrieves the pixel data for the canvas using the getImageData method and passes this data, along with the width and height of the canvas, to the jsQR function. If a QR code is found, it will be logged to the console. |
in which format does the raw data have to be? in my example i tried https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs but i always get |
The data property of the ImageData object represents the pixel data for the canvas as a one-dimensional array of integers, where each integer represents the color of a single pixel in the canvas. The jsQR function expects this data to be in the RGBA format, with each pixel represented by four consecutive integers in the array, representing the red, green, blue, and alpha values of the pixel, respectively. It looks like you're trying to use a data URL as the source for the image that you're drawing onto the canvas. A data URL is a URI scheme that allows you to include the data for a file directly in the URL, rather than linking to an external file. To use a data URL as the source for an image, you can set the src attribute of the Image object to the data URL, like this:
Keep in mind that the data URL must be properly formatted and must include the correct MIME type and encoding for the data that it contains. If the data URL is not formatted correctly, or if the MIME type or encoding is incorrect, the image may not be displayed correctly, or may not be displayed at all. If you're still having trouble getting the jsQR function to work with your canvas data, it might be helpful to check the console for error messages or to log the imageData object to the console to see if there are any issues with the pixel data that you're passing to the jsQR function. |
I have canvas data, as blob, how can i pass it to this library?
The text was updated successfully, but these errors were encountered: