Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Java get image from BufferedImage Zxing QR Code

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi my question is the next, im doing a qr code in java with zxing jar.

I create the qr code and save in my computer, but i dont want write the qr code in the computer, i want get the image for use inside my code and add in a pdf file.


My code is the next





In this code im writing the image in the computer, i was thinking in return the BitMatrix object and make the conversion to image, and save in a image variable. But i dont know how to get the image.
 
Marshal
Posts: 71699
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's Zxing? Is it a kind of exclusive or, or an app for picture manipulation?

Discussion added to our GUIs forum.
 
mike salazar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:What's Zxing? Is it a kind of exclusive or, or an app for picture manipulation?

Discussion added to our GUIs forum.



Is a library for make barcode or qr code
Staff note (Ron McLeod) :

Project repository: https://github.com/zxing/zxing

 
Master Rancher
Posts: 4084
37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

how to get the image.


Are you asking about the variable named image declared on line 26?
 
mike salazar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:

how to get the image.


Are you asking about the variable named image declared on line 26?



no sorry, my question is about this




in this line is writting the image to the path in the computer, i want return the image instead of write the image to the path
 
Norm Radder
Master Rancher
Posts: 4084
37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i want return the image


To return an object from a method, declare the method to return the class of the object and use a return statement to return the object.
Look at the java tutorial:  https://docs.oracle.com/javase/tutorial/java/javaOO/returnvalue.html
 
Sheriff
Posts: 22055
113
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use MatrixToImageWriter to write a BitMatrix to a file or an output stream, or convert it into a BufferedImage. How that can be embedded in a PDF file depends on the PDF library you use.
 
Saloon Keeper
Posts: 23011
156
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This might be of service: https://stackoverflow.com/questions/10354858/qr-code-generation-into-scalable-eps-with-java

Since QR codes are images there are several ways to put them in a PDF. The two primary ways are as a bitmapped image or as PostScript. Bitmapped images originally were in TIFF form, but as far as I know, modern PDFs can handle things like PNG directly.

PostScript (and SVG) are the better option, since they're actual graphic commands and render cleanly regardless of how you zoom in or out or print. Bitmapped images can become blurred or distorted when scaled. PostScript, incidentally, is the "machine language" of PDFs and EPS.

PostScript is a programming language, so if desired you could actually generate a rendering program PS function for QR output and feed it a string of bit values. Or, take the easy way out and just render a matrix of black and white rectangles.
 
I'm not sure if I approve of this interruption. But this tiny ad checks out:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic