Change QR Code Color using Java

This brief tutorial guides how to change QR code color using Java. It has the details about setting the IDE for the development, a list of steps defining the programming logic, and a sample code to draw a QR code on color background using Java. Different customization techniques are shared for changing the format of the output image according to the user’s requirements.

Steps to Change Color of QR Code using Java

  1. Establish the environment to use Aspose.BarCode for Java for creating colored QR code
  2. Instantiate the BarCodeGenerator object and set the encode type to QR using the EncodeTypes enumerator
  3. Set the text for encoding in the QR image
  4. Set the background color using the setBackColor() in the Parameters collection
  5. Define the output image type using the BarCodeImageFormat enumerator
  6. Save the QR code image in the defined format

These steps describe how to develop a colored QR code generator using Java. Instantiate the BarcodeGenerator instance, set the encoding type to QR, and set the text for encoding in the QR code image. Finally, define the color parameter of the BarcodeGenerator and save the output image in the required format.

Code to Create Colored QR Code using Java

This brief code snippet presents the running sample for creating a Yellow QR code using Java. The BarCodeImageFormat provides options such as BMP, GIF, TIFF, SVG, and EMF. The color enumerator contains a long list of colors that you may use for setting the background color, however, the QR image remains black in the final output.

In this article, we have learned how to generate colored QR code using Java. To generate an EAN13 barcode, refer to the article on Generate EAN13 barcode in Java.

 English