QR Code Chaos Talk (i)

Source: Internet
Author: User

    • Reason  

Prompted straw man write this series (will be) the reason is that the two-dimensional code is now very popular, it is easy to contact, and the QR code is so easy to generate-not to say there are many online generators, many applications also have to generate two-dimensional code functions, such as Firefox browser, QQ and so on.

At first, straw man saw that the fancy QR code generated by QQ wanted to write the program that generated its own favorite QR code.

  

    • Spoof

When I started to understand the QR code (later mainly the QR code), I know that it was developed by Denso Company in September 1994, a matrix two-dimensional code symbol, it has a one-dimensional bar code and other two-dimensional barcode has a large information capacity, high reliability, Can be expressed in Chinese characters and images of a variety of text information, security strong security and other advantages. --From the Baidu Encyclopedia is not so easy to achieve, why not easy to steal a high-cornered figure can explain

  

If you stare at these pictures, you will be frightened, the whole very cow look (not say no cow ah). So decided to spoof first, is to first make a seemingly two-dimensional code of the figure.

  

1  PackageSpoofqrcode;2 3 ImportJava.awt.Color;4 ImportJava.awt.Graphics2D;5 ImportJava.awt.image.BufferedImage;6 ImportJava.io.FileOutputStream;7 Importjava.io.IOException;8 ImportJavax.imageio.ImageIO;9 Ten  Public classCreatQRImage2 { One      A      Public StaticString m_content =NULL; -     Private StaticString[] m_numcoding = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", -"1001"}; the     Private StaticString m_strcoding =NULL; -      -      PublicCreatQRImage2 (String content) { -          This. m_content =content; + numtostrcoding (); -     } +      Public Static voidnumtostrcoding () { A          for(intn = 0;n < M_content.length (); n++) at{ for(inti = 0; i < m_numcoding.length; i++){ -             //System.out.println (Content.charat (n) +1); -             if(M_content.charat (n)-48 = =i) -                 { -                 //System.out.println ("OK"); -                 //System.out.println (Numcoding[i]); inM_strcoding + =M_numcoding[i]; -                  Break; to                 } +             Else Continue; -         } the         } *     } $      Public Static voidCreat (intImgsize,string imageformat,string Topath)throwsioexception{Panax NotoginsengFileOutputStream fos =NULL; -BufferedImage buffimg =NULL; the         Try{ +              ABuffimg =Newbufferedimage (imgsize, imgsize, Bufferedimage.type_int_rgb); theGraphics2D GS =Buffimg.creategraphics ();  + Gs.setbackground (Color.White);  -Gs.clearrect (0, 0, Imgsize, imgsize); $ Gs.setcolor (color.black); $              for(inti = 0;i <= 6;i++) -                  for(intj = 0;j <= 6;j++) -                     if(i==0| | j==0| | i==6| | J==6) the{Gs.fillrect (i*8,j*8,8,8);} -              for(inti = 14;i <= 20;i++)Wuyi                  for(intj = 0;j <= 6;j++) the                     if(i==14| | j==0| | i==20| | J==6) -{Gs.fillrect (i*8,j*8,8,8);} Wu              for(inti = 0;i <= 6;i++) -                  for(intj = 14;j <= 20;j++) About                     if(j==14| | i==0| | j==20| | I==6) ${Gs.fillrect (i*8,j*8,8,8); -                          -                         } -Gs.fillrect (2*8,2*8,24,24); AGs.fillrect (16*8,2*8,24,24); +Gs.fillrect (2*8,16*8,24,24); the             //Gs.setcolor (color.blue); -             intStrcodingindex = 4; $             intx = 0; the             inty = 0; the              for(intK = strcodingindex;k < M_strcoding.length (); k++){ the                 //System.out.println ("OK"); the                 //System.out.println (Strcoding.charat (k)); -                         if(X > 20) in                         { theY + = 1; theX-= 20; About                         } the                         if(! (x<7&&y<7) &&! (13<x&&y<7) &&! (13<y&&x<7)) theGs.fillrect (x*8,y*8, the(M_strcoding.charat (k) -48) *8, (M_strcoding.charat (k)-48) *8); +X + +; -                         if(x==21&&y==20&&k<m_strcoding.length ()) { theSystem.out.println ("oversize!");BayiStrcodingindex =K; the                              Break; the                         } -                         if(X<21&&y<=20&&k==m_strcoding.length ()-1){ -System.out.println ("Small data!"); theStrcodingindex =K; the                              Break; the                         } the  -             } the              the Gs.dispose ();  the Buffimg.flush ();94fos=NewFileOutputStream (topath); the Imageio.write (buffimg, ImageFormat, FOS); the         }  the 98         Catch(Exception e) { About e.printstacktrace (); -             }101         finally{102                 if(fos!=NULL){103 fos.close ();104                 }} the     }106 107      Public Static voidMain (string[] args)throwsioexception{108         intImgsize = 168;109String imageformat = "png"; theString Topath = "F:/z27.png";111String content = "15162100138093948324385427385237923464085535342427" the+ "524378523234233343425673143325889543465754602394784752937307";113CreatQRImage2 obj =NewCreatQRImage2 (content); the obj.creat (imgsize,imageformat,topath); the          the     }117}
View Code

That way, you get the result--

  

    • Anyway

I know you will say "blind my dog Eye", this is what, first of all do not say code (can't look straight, I just figure convenient), this QR code also can't sweep ah. Let go of the calm, and I slowly said ...

1. Do you see a "two-dimensional code" appearance (don't look at it)? OK, so that means at least some places are right.

2. Say my idea, the generation of two-dimensional code map, is to write on a "white cloth" on a number of black and whites (shades) of the block, "Black" (dark) stands for "1", "White" (light) represents "0", so that the data can be stored.

  

New= buffimg.creategraphics ();    Gs.setbackground (color.white);  Gs.clearrect (0, 0, imgsize, imgsize);
"White cloth"
Gs.setcolor (Color.Black); Gs.fillrect (X,y,width,height);
"Black Block"

  

3. The biggest problem is the "black" (dark), "white" (light) rules and algorithms on the "cloth". To be able to be identified by a scanner provided by other parties, the format is standardized. To make the generated two-dimensional code can "quick response" and so on need algorithm.

    • Next article

 If straw man such nonsense you can not endure, of course, also may be interested in the two-dimensional code, then first look at http://wenku.baidu.com/link?url=0BOpyLC5YOUTmdip7PlHIWOUihTQKQJJyVE_ 0EM9LEZDA94FGGHROYRMTCOTN1OOZW5GC-YPRGTAYABWGH1QBBYJADU3YXB8WDUG_YPUFWG(QRCode encoding and decoding standard). In this case, the next article should be realized.

Special NOTICE: Reprint please indicate original link

QR Code Chaos Talk (i)

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.