当前位置:网站首页>QR code generation and analysis
QR code generation and analysis
2022-06-30 09:24:00 【LongtengGensSupreme】
#region QR code
int i = 2;
/// <summary>
/// Generate qr code
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnProduct_Click(object sender, EventArgs e)
{
ThoughtWorks.QRCode.Codec.QRCodeEncoder endocder = new ThoughtWorks.QRCode.Codec.QRCodeEncoder();
// QR code background color
endocder.QRCodeBackgroundColor = System.Drawing.Color.White;
// QR code encoding method
endocder.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE;
// The width of each small square
endocder.QRCodeScale = 4;
// QR code version number
endocder.QRCodeVersion = 5;// Control version , Different versions , The displayed styles are different
// Error correction level
endocder.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.M;
var person = new { Id = ++i, Name = "wolfy", Gender = 1, Age = 24 + ++i };
// take json Chuancheng QR code
using (Bitmap bitmap = endocder.Encode(new JavaScriptSerializer().Serialize(person), System.Text.Encoding.UTF8))
{
//Bitmap bitmap = endocder.Encode(new JavaScriptSerializer().Serialize(person), System.Text.Encoding.UTF8);
var strSavePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"QRCode{i}.jpg");
strSavePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"QRCode.jpg");
if (!Directory.Exists(Path.GetDirectoryName(strSavePath)))
{
Directory.CreateDirectory(strSavePath);
}
//System.Runtime.InteropServices.ExternalException:
// Save the image in the wrong image format . - or - The image has been saved to the same file from creating it . Generally, the problem is to save the passage , perhaps aspnet Read and write file permissions
bitmap.Save(strSavePath, System.Drawing.Imaging.ImageFormat.Jpeg);
pbxPicture.SizeMode = PictureBoxSizeMode.Zoom;
//pbxQRCode.Image = Bitmap.FromHbitmap(bitmap.GetHbitmap());
// The first drawing
IntPtr hBitmap = bitmap.GetHbitmap();
pbxQRCode.Image = Bitmap.FromHbitmap(hBitmap);
//pbxQRCode.Image.Save(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"QRCode.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
DeleteObject(hBitmap);
bitmap.Dispose();
// The second drawing
//Graphics graphics = Graphics.FromImage(bitmap);
//graphics.Clear(Color.White);
Again bitmap Draw on
//graphics.DrawImage(new Bitmap(""), new PointF(0, 0));
//graphics.Dispose();
}
// Decrypt QR code
//ThoughtWorks.QRCode.Codec.QRCodeDecoder qRCodeDecoder = new ThoughtWorks.QRCode.Codec.QRCodeDecoder();
//var decoderResult = qRCodeDecoder.decode(new ThoughtWorks.QRCode.Codec.Data.QRCodeBitmapImage(new Bitmap(strSavePath)));
}
/// <summary>
/// Decrypt QR code
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnConsume_Click(object sender, EventArgs e)
{
var strSavePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"QRCode{i}.jpg");
strSavePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"QRCode.jpg");
ThoughtWorks.QRCode.Codec.QRCodeDecoder qRCodeDecoder = new ThoughtWorks.QRCode.Codec.QRCodeDecoder();
var decoderResult = qRCodeDecoder.decode(new ThoughtWorks.QRCode.Codec.Data.QRCodeBitmapImage(new Bitmap(strSavePath)));
lblTakephotoSavePath.Text = $" QR code :{decoderResult}";
}
#endregion边栏推荐
- Deep Learning with Pytorch- A 60 Minute Blitz
- Dart asynchronous task
- 4. use ibinder interface flexibly for short-range communication
- Express の Hello World
- Do you want the dialog box that pops up from the click?
- Esp32 things (3): overview of the overall system design
- Express get request
- 将线程绑定在某个具体的CPU逻辑内核上运行
- Concatapter tutorial
- Solution to the eighth training competition of 2020 Provincial Games
猜你喜欢

Mmdet line by line deltaxywhbboxcoder

Express の Hello World

Set, map and modularity

Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which

Rew acoustic test (II): offline test

Introduction to the runner of mmcv

Maxiouassigner of mmdet line by line interpretation

Summary of Android knowledge points and common interview questions

Handwriting sorter component

8.8 heap insertion and deletion
随机推荐
Rew acoustic test (III): generate test signal
2020-11-02
Code management related issues
List set export excel table
Application of hongruan face recognition
Opencv learning notes -day 11 (split() channel separation function and merge() channel merge function)
C accesses mongodb and performs CRUD operations
Linear-gradient()
Mmdet line by line deltaxywhbboxcoder
Deep Learning with Pytorch-Train A Classifier
Express の Hello World
Generate directory in markdown
Installation, use and explanation of vulnerability scanning tool OpenVAS
[JPEG] how to compile JPEG turbo library files on different platforms
Wechat development tool (applet)
12. problem set: process, thread and JNI architecture
About MySQL Boolean and tinyint (1)
Explanation on the use of password profiteering cracking tool Hydra
Talk about how the kotlin collaboration process establishes structured concurrency
[paid promotion] collection of frequently asked questions, FAQ of recommended list