gpt4 book ai didi

java - 在 Code39Bean 中禁用条形码图像下方的文本

转载 作者:行者123 更新时间:2023-11-30 08:23:59 25 4
gpt4 key购买 nike

此代码创建 BarCode Image 以及 Text below image 。我需要从图像中删除文本。Code39Bean 没有任何属性来禁用它。

public static ByteArrayOutputStream generateBarcodeImg(String inputId)
throws Exception {

ByteArrayOutputStream baos = new ByteArrayOutputStream();

Code39Bean bean = new Code39Bean();
final int dpi = 150;

/**
* Configure the bar-code generator and makes the narrow bar width
* exactly one pixel.
*/
bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi));
bean.setWideFactor(3);
bean.doQuietZone(false);

try {

/** Set up the canvas provider for monochrome PNG output. */
BitmapCanvasProvider canvas = new BitmapCanvasProvider(baos,
BarCodeConstant.CONTENT_TYPE, dpi,
BufferedImage.TYPE_BYTE_BINARY, false, 0);

/** Generate the bar code. */
bean.generateBarcode(canvas, inputId);

/** Signal end of generation. */
canvas.finish();
} catch (IOException e) {
logger.error(
"Exception occured in BarcodeGeneration: generateBarcodeImg "
+ e.getLocalizedMessage(), e);
throw new MobileResourceException(
"Exception occured in BarcodeGeneration: generateBarcodeImg",
null);
}
return baos;

}
}

最佳答案

您可以通过“HumanReadablePlacement”属性从图像中删除文本:

bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);

这会将条形码的人类可读文本抑制为无。

关于java - 在 Code39Bean 中禁用条形码图像下方的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23284785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com