Java QR Code tool class

Source: Internet
Author: User
Tags string format

   Private StaticFinalintBLACK =0xff000000; Private StaticFinalintWhite =0xFFFFFFFF; PrivateMatrixtoimagewriter () {} Public Staticbufferedimage tobufferedimage (Bitmatrix matrix) {intwidth =matrix.getwidth (); intHeight =matrix.getheight (); BufferedImage Image=Newbufferedimage (width, height, bufferedimage.type_int_rgb);  for(intx =0; x < width; X + +) {        for(inty =0; Y < height; y++{Image.setrgb (x, y, matrix).Get(x, y)?black:white); }     }     returnimage; }          Public Static voidWriteToFile (Bitmatrix matrix, String format, file file) throws IOException {bufferedimage image=tobufferedimage (matrix); if(!imageio.write (image, format, file)) {       Throw NewIOException ("Could not write an image of format"+ Format +" to"+file); }   }          Public Static voidWriteToStream (Bitmatrix matrix, String format, OutputStream stream) throws IOException {BufferedImage imag E=tobufferedimage (matrix); if(!imageio.write (image, format, stream)) {       Throw NewIOException ("Could not write an image of format"+format); }   }

Java QR Code tool class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.