Comments (4)
Hi @Codeshark-NET ,
I added an parameter named "drawQuietZones". If you set it to false, the quiet zones around the QR code won't be drawn. If you want to see the changes, have a look at 81e6ea9
Also you wrote about CSS, so it sounds like you want to embed the QR code inside a web application. Have you seen that the library also supports SVG as output format? https://github.com/codebude/QRCoder/blob/master/QRCoder/SvgQRCode.cs
from qrcoder.
Hey Codeshare-NET,
you could change the GetGraphic method. There you could edit the both for loops which render the QRCode graphics by increment/decrementing the loop-count by the border's width.
Or you'll wait 2-3 days and I'll do it and update the project... But it's open source - so just try it! ;-)
from qrcoder.
public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = false)
{
StringBuilder svgFile = new StringBuilder($@"<svg version=""1.1"" baseProfile = ""full"" width=""{viewBox.Width}"" height=""{viewBox.Height}"" xmlns=""http://www.w3.org/2000/svg"">");
int unitsPerModule = (int)Math.Floor(Convert.ToDouble(Math.Min(viewBox.Width, viewBox.Height)) / qrCodeData.ModuleMatrix.Count);
var size = (qrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 6)) * unitsPerModule;
int offset = drawQuietZones ? 0 : 3 * unitsPerModule;
int drawableSize = size + offset;
for (int x = 0; x < drawableSize; x = x + unitsPerModule)
{
for (int y = 0; y < drawableSize; y = y + unitsPerModule)
{
var module = qrCodeData.ModuleMatrix[(y + unitsPerModule) / unitsPerModule - 1][(x + unitsPerModule) / unitsPerModule - 1];
svgFile.Append($@"<rect x=""{x - offset}"" y=""{y - offset}"" width=""{unitsPerModule}' height=""{unitsPerModule}"" fill=""{(module ? darkColorHex : lightColorHex)}"" />");
}
}
svgFile.Append(@"</svg>");
return svgFile.ToString();
}
code style is c# 6
from qrcoder.
Hey @gujunxiong ,
thanks for your work. I added it with minimal changes to the repository. 4cf2d42
from qrcoder.
Related Issues (20)
- Tests for old .NET Frameworks HOT 2
- Documentation issue: URLs HOT 1
- Time Zone in Calendar events HOT 1
- WiFi Payload Won't Generate Correctly HOT 2
- Module size (note pixelsPerModule) HOT 1
- PlatformNotSupportedException when trying to generate QR Code. HOT 2
- Intelligent Mail, IM, postal barcode support? HOT 3
- Memory leak occurs when QR codes used Base64QRCode class HOT 4
- How to generate qr code with transparent background? HOT 2
- 更新到1.4.3,SvgQRCode没有了 HOT 4
- Why not use Color struct instead of byte[] in color parameters? HOT 1
- PayloadGenerator.WiFi.Authentication.WPA2 missing HOT 2
- Can Create a QR with shapes of my logo HOT 1
- Sample code fails - "QRCode" doesn't exist HOT 5
- Guidance on artistic QR codes HOT 1
- Trying to Convert a SVG QRCODE to PNG file HOT 3
- PayloadGenerator give the same result HOT 2
- How to read the code from image HOT 2
- Qr-code
- The type initializer for 'SkiaSharp.SKData' threw an exception. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qrcoder.