Comments (2)
How do you try to resize? I reckon you tried to create a normal QR Code via QRCode class and then resize the resulting Bitmap of the GetGraphic method.
In this case it's clear that you get bad quality graphics, because the you are working on a Bitmap which has image information pixel by pixel. When resizing the quality shrinks because you have information loss.
For now I can think of three solutions:
- When calling the GetGraphic method set the parameter "pixelsPerModule". This parameter tells the QRCoder how much pixels each black (or white) block should have on it's outer sides. So for example: The QR Code exists of 21 blocks. If you set pixelsPerModule to 10 the resulting QR Code will have a width of ~210 pixel.
- Use the SvgQRCode class instead of QRCode. It returns the QRCode in SVG format which is an vector format. (Vector graphics can be resized without quality loss.)
- Implement your own renderer. All QRCode types are implemented in the same manner. Just create a new class, ChenchiQRCode.cs for example, which inherits from AbstractQRCode. Then override the GetGraphic method and implement your own renderer. The module information (the white and black blocks) is stored in this.QrCodeData.ModuleMatrix which can be used in the overridden GetGraphics class.
Just let me know if this solved your problem. If you implemented your own QRCode type feel free to push it to this repository.
from qrcoder.
If I increase the dpi of the image and then resize the image, will it work?
Like this:
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
{
QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText, QRCodeGenerator.ECCLevel.Q);
using (QRCode qrCode = new QRCode(qrCodeData))
{
Bitmap qrImage = qrCode.GetGraphic(2);
qrImage.MakeTransparent(Color.Transparent);
Bitmap resizedImage = new Bitmap(qrImage, new Size(82, 82));
qrImage.SetResolution(400, 400);
string fileName = $"{Part_Number}_QTYTOTAL.png";
string filePath = Path.Combine(folderPath, fileName);
qrImage.Save(filePath, ImageFormat.Png);
}
}
from qrcoder.
Related Issues (20)
- What is the purpose of `forceUtf8`? HOT 4
- URL generator doesn't work HOT 2
- want to generate SVG file of 2.5cm which contain 2600Bytes of data to SCAN in QR any suggestion HOT 5
- Some Payload generators miss overriding EciMode and EccLevel
- Issue was in the last digit of QR Code. It was showing (. * - + and Sometimes X Y A B Z). The String is M*******7202 * is as Character. HOT 3
- Cannot use 5 argument version of QRCode constructor under Windows .net 8.0 with Nuget 1.5.1 HOT 9
- [Feature] Trimmability
- [WIP] How do we split the QRCoder? (NuGet packages) HOT 3
- [WIP/QRCoder2] How do we split the QRCoder? (Github repositories) HOT 1
- [WIP/QRCoder2] Version number handling HOT 1
- [WIP/QRCoder2] Documentation and wiki HOT 2
- [WIP/QRCoder2] How do we handle changes during the 2.0 development? HOT 2
- [WIP/QRCoder2] Coordination of development (VCS) HOT 1
- [WIP/QRCoder2] Coordination of development (Organization) HOT 1
- [WIP/QRCoder2] Communication tools besides Github? HOT 1
- [WIP/QRCoder2] System.Drawing vs X HOT 2
- [WIP/QRCoder2] Use of System.Drawing.Primitives HOT 1
- [WIP/QRCoder2] How do deal with COM-support? HOT 5
- [WIP/QRCoder2] Shall we re-think the Payload Generator? HOT 7
- [WIP/QRCoder2] Consider Removing QRCodeGenerator Instance Methods
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.