Barcode generator vs builder 18.11

I’m trying to use the new generator api instead of the deprecated builder, but the images does not come out the same.
They are similar… but not exactly the same.
Api version 18.11
Code snippet.

public static void main(String[] args) throws Exception {
	// Apply a license to avoid the evaluation WaterMark in the BarCode image. 
	License license = new License();
	license.setLicense("Aspose.Total.Java.lic");

	final String barcodeValue = "Some text";

	BufferedImage img1 = generatebarcodeDeprecated(EncodeTypes.CODE_39_STANDARD, 395.5f, 77f, barcodeValue);
	ImageIO.write(img1, "png", new File(EncodeTypes.CODE_39_STANDARD + "_OLD" + ".png"));

	BufferedImage img2 = generateBarcodeNew(EncodeTypes.CODE_39_STANDARD,395.5f, 77f, barcodeValue);
	ImageIO.write(img2, "png", new File(EncodeTypes.CODE_39_STANDARD + "_NEW" + ".png"));

	BufferedImage img3 = generatebarcodeDeprecated(EncodeTypes.QR,  155f,  141f, barcodeValue);
	ImageIO.write(img3, "png", new File(EncodeTypes.QR + "_OLD" + ".png"));

	BufferedImage img4 = generateBarcodeNew(EncodeTypes.QR,  155f,  141f, barcodeValue);
	ImageIO.write(img4, "png", new File(EncodeTypes.QR + "_NEW" + ".png"));	
}

@SuppressWarnings("deprecation")
private static BufferedImage generatebarcodeDeprecated(SymbologyEncodeType type, float width, float height, String value) {
	BarCodeBuilder builder = new BarCodeBuilder(value, type);
	builder.setImageWidth(width);
	builder.setImageHeight(height);
	return builder.getOnlyBarCodeImage();
}

private static BufferedImage generateBarcodeNew(SymbologyEncodeType type, float width, float height, String value)  {
	BarCodeGenerator generator = new BarCodeGenerator(type, value);
	generator.recalculateValues();
	generator.getCodeTextStyle().setLocation(CodeLocation.None);
	generator.setAutoSizeMode(AutoSizeMode.NEAREST);
	generator.getBarCodeWidth().setMillimeters(width);
	generator.getBarCodeHeight().setMillimeters(height);
	return generator.generateBarCodeImage();
}

@sillastrypare,

Thanks for the code segment and details.

I tested your sample code with our latest version/fix: Aspose.BarCode for Java v19.3.x. I noticed the output images (by older and newer API) are different only for its dimensions (height/width) or size. Do you mean the same thing? Well, the new API has more flexibility to set the width/height in your desired units (pixels, point, inches, mm, etc.). I think you may either minimize the width/height when setting millimeters or choose respective unit to work for your needs.