当前位置:网站首页>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
边栏推荐
- Reading notes of "Introduction to deep learning: pytoch"
- Express get request
- Pit encountered by fastjason
- Using appbarlayout to realize secondary ceiling function
- 2020-11-02
- Treatment process record of Union Medical College Hospital (Dongdan hospital area)
- Interviewer: do you understand the principle of recyclerview layout animation?
- Design specification for smart speakers v1.0
- Application of hongruan face recognition
- About Lombok's @data annotation
猜你喜欢
Talk about how the kotlin collaboration process establishes structured concurrency
Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
Advanced technology management -- how managers design and build echelons
Challenge transform() 2D
Dart asynchronous task
Anchorgenerator for mmdet line by line interpretation
桂林 稳健医疗收购桂林乳胶100%股权 填补乳胶产品线空白
Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)
Handwriting sorter component
Mmdet line by line deltaxywhbboxcoder
随机推荐
Icon resources
Reading notes of "Introduction to deep learning: pytoch"
List set export excel table
Explanation on the use of password profiteering cracking tool Hydra
Research on lg1403 divisor
Detailed explanation of rect class
Introduction to the runner of mmcv
Pytorch BERT
Esp32 (7): I2S and I2C drivers for function development
使用华为性能管理服务,按需配置采样率
4. use ibinder interface flexibly for short-range communication
Six implementation methods of singleton mode
Opencv learning notes -day4 image pixel reading and writing operations (array traversal and pointer traversal implementation, uchar vec3b data type and mat class functions mat:: at(), mat:: ptr())
Deep Learning with Pytorch- A 60 Minute Blitz
Esp32 (6): Bluetooth and WiFi functions for function development
快应用中实现自定义抽屉组件
Flink sql -- No factory implements ‘org. apache. flink. table. delegation. ExecutorFactory‘.
Baidu map JS browsing terminal
Anchorgenerator for mmdet line by line interpretation
ES6 learning path (IV) operator extension