当前位置:网站首页>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边栏推荐
- Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)
- Comparaison de deux façons d'accéder à la base de données SQL Server (sqldatareader vs sqldataadapter)
- 7. know JNI and NDK
- Opencv learning notes -day2 (implemented by the color space conversion function cvtcolar(), and imwrite image saving function imwrite())
- JVM tuning related commands and explanations
- asdsadadsad
- C # get the current timestamp
- Esp32 things (V): analysis of common API of esp32 of Swiss Army knife
- Express の Hello World
- Maxiouassigner of mmdet line by line interpretation
猜你喜欢

Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)

Maxiouassigner of mmdet line by line interpretation

Deep understanding of continuation principle

Anchorgenerator for mmdet line by line interpretation

5. Messager framework and imessager interface

Agp7.0|kts makes a reinforced plug-in

Bottomsheetbehavior principle of realizing the home page effect of Gaode map

Rew acoustic test (I): microphone calibration

7. know JNI and NDK

Dart asynchronous task
随机推荐
Esp32 things (V): analysis of common API of esp32 of Swiss Army knife
Mmdet line by line code interpretation of positive and negative sample sampler
Script summary
Baidu map JS browsing terminal
ES6 learning path (III) deconstruction assignment
Understanding of MVVM and MVC
Installation, use and explanation of vulnerability scanning tool OpenVAS
Small program learning path 1 - getting to know small programs
Dart asynchronous task
Invalid update: invalid number of sections. The number of sections contained in the table view after
Opencv learning notes -day 11 (split() channel separation function and merge() channel merge function)
Opencv learning notes -day8 (keyboard typing (waitkey()); Wait for typing) action: triggers some action when the appropriate character is typed using the keyboard)
桂林 稳健医疗收购桂林乳胶100%股权 填补乳胶产品线空白
Pytorch BERT
Esp32 things (3): overview of the overall system design
Rew acoustic test (VI): signal and measurement
Generate directory in markdown
Esp32 (IX): OTA function of function development
QT downloading files through URL
Comparison of two ways for C to access SQL Server database (SqlDataReader vs SqlDataAdapter)