当前位置:网站首页>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边栏推荐
- Duplicate entry '2' for key 'primary appears in JPA‘
- Treatment process record of Union Medical College Hospital (Dongdan hospital area)
- What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?
- C accesses mongodb and performs CRUD operations
- Couldn't load this key (openssh ssh-2 private key (old PEM format))
- Use Huawei performance management service to configure the sampling rate on demand
- 【付费推广】常见问题合集,推荐榜单FAQ
- Express の post request
- [protobuf] protobuf generates cc/h file through proto file
- RPC understanding
猜你喜欢

Talk about how the kotlin process started?

Opencv learning notes -day8 (keyboard typing (waitkey()); Wait for typing) action: triggers some action when the appropriate character is typed using the keyboard)

asdsadadsad

Set, map and modularity

Agp7.0|kts makes a reinforced plug-in

Interviewer: do you understand the principle of recyclerview layout animation?

Applet learning path 2 - event binding

Opencv learning notes-day6-7 (scroll bar operation demonstration is used to adjust image brightness and contrast, and createtrackbar() creates a scroll bar function)

Deeply understand the working principle of kotlin collaboration suspend (beginners can also understand it)

7. know JNI and NDK
随机推荐
ES6 learning path (II) let & const
Influencing factors of echo cancellation for smart speakers
Express の Hello World
About Lombok's @data annotation
Set, map and modularity
Opencv learning notes -day3 (mat object and creation related operations mat:: clone(), mat:: copyto(), mat:: zeros(), mat:: ones(), scalar()...)
RPC understanding
I once met a girl whom I most wanted to take care of all my life. Later... No later
12. problem set: process, thread and JNI architecture
Understanding of MVVM and MVC
Rew acoustic test (IV): test principle of rew
Rew acoustic test (VI): signal and measurement
Coredata acquisition in swift sorting, ascending, descending
Opencv learning notes-day9 opencv's own color table operation (colormap coloraptypes enumeration data types and applycolormap() pseudo color function)
Invalid update: invalid number of sections. The number of sections contained in the table view after
Flutter 0001, environment configuration
What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?
Handwriting sorter component
Introduction to the runner of mmcv
Opencv learning notes-day6-7 (scroll bar operation demonstration is used to adjust image brightness and contrast, and createtrackbar() creates a scroll bar function)