Generate Barcode and QR Code with Logo in C#.

We commonly use a barcode to represent encoded data or information about a product or a company in a machine-readable form. Normally, we use barcodes with text labels. However, we can also generate barcodes with company logos or images programmatically in .NET applications. In this article, we will learn how to generate a barcode and QR code with a logo in C#.

The article will cover the following topics:

For generating barcodes with logos or images, we will be using the Aspose.BarCode for .NET API. It allows us to generate and recognize a wide range of 1D and 2D barcode types.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.BarCode

Generate Barcode with Logo in C#

We can generate a barcode with a logo or an image by following the steps given below:

  1. Firstly, create an instance of the BarcodeGenerator class with the EncodeType and text to encode as arguments.
  2. Optionally, set the barcode size value in pixels.
  3. Next, generate a Barcode image using the GenerateBarCodeImage() method and store it in a bitmap.
  4. Then, load the logo image as a bitmap.
  5. After that, create a new empty bitmap image with the height of the logo and the generated barcode image.
  6. Next, initialize the Graphics class object using the FromImage() method. It takes an empty bitmap object as an argument.
  7. Then, clear the canvas using the Clear() method.
  8. Now, call the DrawImage() method to draw the barcode image on the canvas.
  9. After that, call the DrawImage() method again to draw the logo image on the canvas.
  10. Finally, save the output using the Image.Save() method. It takes the output file path as an argument.

The following code example demonstrates how to generate a barcode with a logo image using C#.

Generate Barcode with Logo in C#

Generate Barcode with Logo in C#

C# QR Code Generator with Logo

Similarly, we can also generate a QR code with a logo or an image by following the steps mentioned earlier. However, we need to set the EncodeType as QR in the first step.

The following code example demonstrates how to generate a QR code with a logo image using C#.

Generate QR Code with Logo using C#

Generate QR Code with Logo using C#

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

Logo Barcode Generator – Free Learning Resources

Besides generating barcodes or QR codes with logos, explore various other features of the API using the resources below:

Conclusion

In this article, we have learned how to generate a barcode with a logo image. We have also seen how to generate a QR code with an image programmatically. By leveraging Aspose.BarCode for .NET, you can easily develop your own barcode or QR code generator with a logo in C#. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also