@@ -49,6 +49,48 @@ public void can_render_svg_qrcode_without_quietzones()
49
49
50
50
result . ShouldBe ( "24392f47d4c1c2c5097bd6b3f8eefccc" ) ;
51
51
}
52
+
53
+ [ Fact ]
54
+ [ Category ( "QRRenderer/SvgQRCode" ) ]
55
+ public void can_render_svg_qrcode_with_png_logo ( )
56
+ {
57
+ //Create QR code
58
+ var gen = new QRCodeGenerator ( ) ;
59
+ var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
60
+
61
+ //Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
62
+ var logoBitmap = ( Bitmap ) Bitmap . FromFile ( Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . CodeBase ) . Replace ( "file:\\ " , "" ) + "\\ assets\\ noun_software engineer_2909346.png" ) ;
63
+ var logoObj = new SvgQRCode . SvgLogo ( logoBitmap , 15 ) ;
64
+
65
+ var svg = new SvgQRCode ( data ) . GetGraphic ( 10 , Color . DarkGray , Color . White , logo : logoObj ) ;
66
+
67
+ var md5 = new MD5CryptoServiceProvider ( ) ;
68
+ var hash = md5 . ComputeHash ( System . Text . Encoding . UTF8 . GetBytes ( svg ) ) ;
69
+ var result = BitConverter . ToString ( hash ) . Replace ( "-" , "" ) . ToLower ( ) ;
70
+
71
+ result . ShouldBe ( "4ff45872787f321524cc4d071239c25e" ) ;
72
+ }
73
+
74
+ [ Fact ]
75
+ [ Category ( "QRRenderer/SvgQRCode" ) ]
76
+ public void can_render_svg_qrcode_with_svg_logo ( )
77
+ {
78
+ //Create QR code
79
+ var gen = new QRCodeGenerator ( ) ;
80
+ var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
81
+
82
+ //Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909361
83
+ var logoSvg = File . ReadAllText ( Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . CodeBase ) . Replace ( "file:\\ " , "" ) + "\\ assets\\ noun_Scientist_2909361.svg" ) ;
84
+ var logoObj = new SvgQRCode . SvgLogo ( logoSvg , 30 ) ;
85
+
86
+ var svg = new SvgQRCode ( data ) . GetGraphic ( 10 , Color . DarkGray , Color . White , logo : logoObj ) ;
87
+
88
+ var md5 = new MD5CryptoServiceProvider ( ) ;
89
+ var hash = md5 . ComputeHash ( System . Text . Encoding . UTF8 . GetBytes ( svg ) ) ;
90
+ var result = BitConverter . ToString ( hash ) . Replace ( "-" , "" ) . ToLower ( ) ;
91
+
92
+ result . ShouldBe ( "b4ded3964e2e640b6b6c74d1c89d71fa" ) ;
93
+ }
52
94
#endif
53
95
}
54
96
}
0 commit comments