How to change color qr generating to another color of black
I working in visual studio 2015 windows form application
I generating qr using messagetoolkit library and it working good without any problem
I face only one problem i need to change color of qr to another color different to
black as blue or red or green like that
so that how to do color qr code using messagetoolkit
my code
MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
encoder.QRCodeScale = 8;
Bitmap bmp = encoder.Encode(textBox1.Text);
pictureBox1.Image = bmp;
bmp.Save(sv.FileName, ImageFormat.Jpeg);
Re: How to change color qr generating to another color of black
If that QRCodeEncoder class doesn't provide the ability to specify a colour, you could simply change the colour of the pixels one by one:
csharp Code:
private void ChangePixelColour(Bitmap bmp, Color originalColour, Color newColour)
{
for (var x = 0; x < bmp.Width; x++)
{
for (var y = 0; y < bmp.Height; y++)
{
if (bmp.GetPixel(x, y) == originalColour)
{
bmp.SetPixel(x, y, newColour);
}
}
}
}
GetPixel and SetPixel are slow but performance should be good enough for what is likely to be a relatively small image.