QR code generation and scanning source code download

QR code generation and scanning source code download

The QR code generation and scanning function codes are collected. The scanning function includes the scanning of QR code and barcode, and has a 360 scanning UI effect, as a QR code tool.

Source code introduction

Source code running screenshot

Run screenshot

Scanning of QR codes and barcodes

QR code generation

Source code snippet

  1. /***
  2. *
  3. * @param string The string to generate the QR code
  4. * @param format QR code format
  5. * @return Returns the QR code image
  6. * @throws WriterException
  7. */  
  8. public Bitmap qr_code(String string, BarcodeFormat format)
  9. throws WriterException {
  10. MultiFormatWriter writer = new MultiFormatWriter();
  11. Hashtable<encodehinttype, string= "" > hst = new Hashtable<encodehinttype, string= "" >();
  12. hst.put(EncodeHintType.CHARACTER_SET, "UTF-8" );
  13. BitMatrix matrix = writer.encode(string, format, 400 , 400 , hst);
  14. int width = matrix.getWidth();
  15. int height = matrix.getHeight();
  16. int [] pixels = new   int [width * height];
  17. for ( int y = 0 ; y < height; y++) {
  18. for ( int x = 0 ; x < width; x++) {
  19. if (matrix.get(x, y)) {
  20. pixels[y * width + x] = 0xff000000 ;
  21. }
  22.   
  23. }
  24. }
  25. Bitmap bitmap = Bitmap.createBitmap(width, height,
  26. Bitmap.Config.ARGB_8888);
  27. // Generate bitmap through pixel array, refer to api for details  
  28. bitmap.setPixels(pixels, 0 , width, 0 , 0 , width, height);
  29. return bitmap;
  30. }
  31. </encodehinttype,></encodehinttype,>

Source code download address: http://down..com/data/1968746

<<:  An image picker that mimics iMessage in iOS8

>>:  Cool elastic menu, with horizontal and arc

Recommend

Why can scalpers always get tickets but I can’t?

Audit expert: Zheng Yuanpan, professor at Zhengzh...

Keep Fitness 43 sets of member video collection

Keep Fitness 43 sets of member video collection r...

GAC Trumpchi GA4 is coming soon, and Lavida is not calm

GAC Trumpchi's new compact sedan GA4 was offi...

The biggest lie I've believed in over 20 years: Drinking warms the body

I heard that the setting sun is a signal to drink...

50th Anniversary: ​​Nissan and Italdesign Create the Ultimate GT-R50

To celebrate the 50th anniversary of the GT-R fam...

One reason is enough to persuade you to eat more taro!

When it comes to taro, many people's mouths w...

What is cause marketing? How should companies conduct charity marketing?

Many people think that we are far away from chari...

What is the most important thing in server hosting?

Today, as the trend of global economic integratio...

iOS speech recognition wave animation based on Speech framework

Author : Wu Xinshuang, Family Operations Center L...

Arrange a tea party in Nanjing and find Xiao Wang

Nanjing tea drinking studio arrangement, Nanjing ...