四时宝库

程序员的知识宝库

探秘二维码:你不知道的那些事(二维码的秘密)

在当今数字化时代,二维码已经成为我们生活中不可或缺的一部分。从商店的支付方式到产品的追溯系统,二维码的应用无处不在。那么,二维码究竟是什么?它是如何工作的?它的未来又将走向何方?今天,我们就来一探究竟。

一、二维码的起源与发展

二维码(Quick Response Code,简称QR Code)最早于1994年由日本的Denso Wave公司发明。最初,二维码被设计用于追踪汽车零部件的生产过程。与传统的一维条形码相比,二维码能够存储更多的信息,因为它是以矩阵形式排列的黑白方块。

Golang 二维码生成和识别(golang mq)

今天介绍一下golang第三方库:tuotoo/qrcode ,支持生成二维码和解码二维码图片。以下是使用 tuotoo/qrcode 进行二维码识别(解码)的详细教程:


一、安装tuotoo/qrcode

x-cmd pkg | qrencode - 命令行生成二维码,小白也能轻松上手!

简介

qrencode 是一个用于生成二维码的命令行工具。它可以将文本、URL、电话号码等信息转换为二维码图像。生成的二维码图像可以保存为图片文件,方便在电子文档、网页、移动应用等各种场景中使用。 它支持的二维码是 QR 码,具有信息容量大、可靠性高、可表示汉字及图象等多种文字信息、保密防伪性强等优点,是目前较为常用的二维条码。

更具形式美的二维码工具(更具形式美的二维码工具有哪些)

关于二维码,之前有简单提过“包容万物”的 草料二维码 https://cli.im/


草料二维码可以将文本、网址、文件、图片、音视频等内容,储存在小小的二维码中,并且在不改变二维码图案的前提下,可以随时更改存储的内容。


那么二维码为什么可以“存储”那么多的内容?又为什么可以随时更改呢?先来了解一些基础知识吧~

二维码在线生成器哪些比较好用?二维码 生成器有哪些?

二维码在线生成器哪些比较好用?

随着数字化时代的到来,二维码已经成为人们日常生活中必不可少的一部分。它可以用于信息传递、商品销售、用户身份验证等多种场景,因此,二维码在线生成器也变得越来越受欢迎。

工具类:Java版本二维码生成以及解码

有时候我们经常会想要实现二维码批量生成的功能,这里提供一个二维码生成以及解析的工具类,包括可以上传logo,代码如下:

/**
 * 二维码工具类
 * @date 20198年10月31日
 * @version 1.0
 */
public class QRCodeUtils {
    // 二维码大小
    private static final int QRCODE_SIZE = 300;  
    // 二维码中间logo的尺寸
    private static final int WIDTH  = 60;
    private static final int HEIGHT = 60;
    public static void encode(String content, String logoPath, String imgPath)  throws Exception {  
        encode(content, logoPath, imgPath, QRCODE_SIZE, 1);  
    }
    public static void encode(String content, String logoPath, String imgPath, int size, int margin)  throws Exception {  
        BufferedImage image = createImage(content, logoPath, size, margin);  
        ImageIO.write(image, "png", new File(imgPath));  
    }
    public static void encode(String content, String logoPath, OutputStream output) throws Exception {  
        encode(content, logoPath, output, QRCODE_SIZE, 1);
    }
    public static void encode(String content, String logoPath, OutputStream output, int size, int margin) throws Exception {  
        BufferedImage image = createImage(content, logoPath, size, margin);  
        ImageIO.write(image, "png", output);  
    }
    private static BufferedImage createImage(String content, String imgPath, int size, int margin) throws Exception {  
        Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();  
        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);  
        hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");  
        hints.put(EncodeHintType.MARGIN, margin); 
        BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, size, size, hints); 
        int[] rec = bitMatrix.getEnclosingRectangle();  
        int resWidth  = rec[2] + 1;  
        int resHeight = rec[3] + 1;  
        BitMatrix resMatrix = new BitMatrix(resWidth, resHeight);  
        resMatrix.clear();  
        for (int i = 0; i < resWidth; i++) {  
            for (int j = 0; j < resHeight; j++) {  
                if (bitMatrix.get(i + rec[0], j + rec[1])) { 
                     resMatrix.set(i, j); 
                } 
            }  
        }  
        int width  = bitMatrix.getWidth();  
        int height = bitMatrix.getHeight();  
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);  
        for (int x = 0; x < width; x++) {  
            for (int y = 0; y < height; y++) {  
                image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);  
            }  
        }  
        if (imgPath == null || "".equals(imgPath)) {  
            return image;  
        }  
        // 插入图片  
        insertImage(image, imgPath, size);  
        return image;  
    }  
    private static void insertImage(BufferedImage source, String imgPath, int size) throws Exception {  
        File file = new File(imgPath);  
        if (!file.exists()) {  
            System.out.println(""+imgPath+"   该文件不存在!");  
            return;  
        }  
        Image src  = ImageIO.read(new File(imgPath));  
        int width  = src.getWidth(null);  
        int height = src.getHeight(null);
        // 压缩LOGO
        if (width > WIDTH) {  
            width = WIDTH;  
        }  
        if (height > HEIGHT) {  
            height = HEIGHT;  
        }  
        Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);  
        BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);  
        Graphics g = tag.getGraphics();  
        g.drawImage(image, 0, 0, null); // 绘制缩小后的图  
        g.dispose();  
        src = image;  
        // 插入LOGO  
        Graphics2D graph = source.createGraphics();  
        int x = (size - width) / 2;  
        int y = (size - height) / 2;  
        graph.drawImage(src, x, y, width, height, null);  
        Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);  
        graph.setStroke(new BasicStroke(3f));  
        graph.draw(shape);  
        graph.dispose();  
    }  
    public static String decode(File file) throws Exception {  
        BufferedImage image;  
        image = ImageIO.read(file);  
        if (image == null) {  
            return null;  
        }  
        BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);  
        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));  
        Result result;  
        Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();  
        hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");  
        result = new MultiFormatReader().decode(bitmap, hints);  
        return result != null ? result.getText() : null;  
    }  
    public static void main(String[] args) throws Exception {
        QRCodeUtils.encode("https://www.suibibk.com/blog/579412311547052032/582955445098905600/639208466002477056", "e:/logo.jpg", "e:/qrcode.png");
        // 解析二维码存储的内容并打印
        System.out.println(decode(new File("e:/qrcode.png")));
    }
}

那些超好用并且在Chrome商店超过10万用户的JSON格式化插件

原文链接:

https://www.lskyf.com/post/51

JSON Formatter

下载地址

http://cj.lskyf.com/mhimpmpmffogbmmkmajibklelopddmjf.html

用户数:989,391 4.5星 推荐理由:没有跟踪,没有广告,没有别的邪恶。

你能搞定二维码吗?2分钟包教包会 | #全民求知季

本文有小虾同学VX公众号xxtx2018发布。我们是一群一线信息技术教师,学无止境,怕只怕不愿意接受和学习新鲜事物,小虾童鞋愿与你一起学习、一起成长,关注读书、职场以及信息技术的巧妙应用,从细节处提升生活的幸福感,从点滴处促进工作的高效能!


二维码在线生成器如何使用?长连接转化成短连接如何实现?

二维码在线生成器如何使用?长连接转化成短连接如何实现

随着互联网的发展,人们使用网络的方式也越来越多样化。其中,二维码成为了人们连接网络的一种重要方式。下面,我们将介绍二维码在线生成器以及如何将长连接转化成短连接。

二维码生成解析用ZXing.NET就够了,不要再引一堆生成和解析库了

ZXing.NET 是一个开源的、功能强大的二维码处理库,它能够对二维码进行解码(读取信息)和编码(生成二维码)。ZXing 是 "Zebra Crossing" 的缩写,是一个跨平台的、用于解码和生成条形码和二维码的库。以下是一些 ZXing.Net 的主要功能通过实例讲解。

<< < 1 2 3 4 5 6 7 > >>
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言
    友情链接