Our Customers
Contact Us Email: support@barcodelib.com
Home > .NET Barcode > C# Barcoding Guide > How to Set & Adjust Barcode Image Color in C#.NET Projects
Download Barcode for .NET Suite Trial

How to Set QR Code Color Using C#

Use C#.NET Class Code to Change & Customize QR Code Color Settings
  • Highly-credited C#.NET QR Code barcode image generator component
  • Easy to change & reset generated QR Code colors in C#.NET applications
  • Customize colors of QR Code in ASP.NET & WinForms projects using C# code
  • Able to generate & print QR Code image with different background colors
  • Free to set module color of created QR Code images using C#.NET class library
  • Generated colorful QR Code images are compatible with industry standards
C#.NET QR Code Barcode Generator Overview
C#.NET QR Code Barcode Generator from BarcodeLib.com is a time-tested QR Code barcoding component since 2003. It can not only generate high-quality QR Code images but makes it extremely easy for users to change & set QR Code image colors, including background color and bar color.
Generate & Change QR Code Color in C# Class
Before customizing QR Code color settings, users have to install .NET, C#.NET barcode generating dlls first.

Installation

  • Locate Barcodelib.Barcode.ASP.NET.dll or BarcodeLib.Barcode.WinForms.dll from downloaded trial package.
  • Integrate either of those two barcode generating dlls into your C# project by adding reference.
  • Integrate either of those two barcoding dlls into the Visual StudioToolbox.

Implementation

You can change QR Code image colors easily using following free sample C# class codes.
     // Generate & print QR Code image using C#
     BarcodeLib.Barcode.QRCode qrbarcode = new BarcodeLib.Barcode.QRCode();
     qrbarcode.Encoding = BarcodeLib.Barcode.QRCodeEncoding.Auto;
     qrbarcode.Data = "ABCD1234abcd";
     qrbarcode.ModuleSize = 3;
     qrbarcode.LeftMargin = 12;
     qrbarcode.RightMargin = 12;
     qrbarcode.TopMargin = 12;
     qrbarcode.BottomMargin = 12;

     // Change module color & background color of QR Code
     qrbarcode.BackgroundColor = System.Drawing.Color.White;
     qrbarcode.ModuleColor = System.Drawing.Color.Blue;

     // Save generated QR Code image to pgn image format file
     qrbarcode.drawBarcode("c:/qrcode.png");
Generate & Print Colorful QR Code in ASP.NET Web Page & IIS

Change QR Code Barcode Colors in ASP.NET Web Page

  • Add "Barcodelib.Barcode.ASP.NET.dll" to your ASP.NET project by reference.
  • Add "Barcodelib.Barcode.ASP.NET.dll" to the VS toolbox by choosing item.
  • Copy files "qrcode.aspx", "qrcode.aspx.cs" from folder barcode in the downloaded package to your ASP.NET project folder.
  • Drag QRCodeASPNET to your ASP.NET web site, and change QR code colors through "Properties" window.

Change QR Code Barcode Colors in IIS

  • Find folder "barcode" from downloaded trial package and copy it to your IIS folder, eg. C:\inetpub.
  • Create a new virtual directory in your IIS, name it "barcode", and connect it to the above "barcode" folder in inetpub. Then, restart IIS.
  • Open your web browser and navigate to:
    "http://YourDomain:port/barcode/qrcode.aspx?Data=ABCD1234abcd&ModuleSize=3 &LeftMargin=12&RightMargin=12&TopMargin=12&BottomMargin=12&BackgroundColor=FFFFFF&ModuleColor=000079"
  • To insert this QR Code image in your aspx or html page, simply pass the url to IMG tag or src value.
    For example: <img src= http://YourDomain:port/barcode/qrcode.aspx?Data=ABCD1234abcd&ModuleSize=3 &LeftMargin=12&RightMargin=12&TopMargin=12&BottomMargin=12&BackgroundColor=FFFFFF&ModuleColor=000079>
    This method will not generate any barcode images in your IIS server side.
Change & Customize QR Code Color in C#.NET WinForms
  • Add BarcodeLib.Barcode.WinForms.dll to your C#.NET Windows Forms project reference.
  • Add BarcodeLib.Barcode.WinForms.dll to Visual Studio Toolbox.
  • Drag the QRCodeWinForm to your windows form.
  • Adjust module color & background color using "Properties" window.
All Supported Linear & 2D Barcode Types
Linear Barcode Types:
Matrix Barcode Types: