簡體   English   中英

為什么燒烤條形碼庫會生成與其他條形碼生成器不同的圖像?

[英]Why is the Barbecue Barcode library generating a different image from other Barcode generators?

我遇到燒烤條形碼庫的問題。 我正在嘗試創建一個簡單的code128條形碼,但我獲得的圖像與我從其他在線(即http://barcode-generator.org )和桌面(即Zing)條形碼生成器獲得的圖像不同。

這是我正在使用的ColdFusion代碼:

<cfscript>
    LOCAL.BarcodeData = "10047846";
    LOCAL.BarcodeFactory = CreateObject("java", "net.sourceforge.barbecue.BarcodeFactory");
    LOCAL.Barcode = LOCAL.BarCodeFactory.createCode128(LOCAL.BarcodeData);
    LOCAL.BarcodeImageHandler = CreateObject("java", "net.sourceforge.barbecue.BarcodeImageHandler");
    LOCAL.BarcodeBufferedImage = LOCAL.BarcodeImageHandler.getImage(LOCAL.Barcode);
    LOCAL.BarcodeImage = ImageNew(LOCAL.BarcodeBufferedImage);
    LOCAL.BarcodeImagePath =
        "C:\temp_\barcode-" & LOCAL.BarcodeData & ".jpg";
    ImageWrite(LOCAL.BarcodeImage, LOCAL.BarcodeImagePath, 1);
</cfscript>
<cfimage action="writeToBrowser" source="#LOCAL.BarcodeImagePath#" />

這將輸出以下圖像:

燒烤生成的條形碼10047846

然而,這是我從Zing桌面程序得到的:

在此輸入圖像描述

這是我從barcode-generator.org得到的:

在此輸入圖像描述

現在,我對尺寸,縮放等沒有任何問題。但是,您可以輕松地告訴燒烤生成的圖像有很大不同 - 只需看看前幾個條形圖。

為什么會這樣? 這是燒烤蟲還是我做錯了什么?

不確定這是“答案”本身,但是,當我更改代碼以使用Code128C格式時,圖像按預期出現。 我只需要做一些調整大小,以獲得我所需的大小:

在此輸入圖像描述

碼:

<cfscript>
    LOCAL.BarcodeData = "10047846";
    LOCAL.BarcodeFactory = CreateObject("java", "net.sourceforge.barbecue.BarcodeFactory");
    LOCAL.Barcode = LOCAL.BarCodeFactory.createCode128C(LOCAL.BarcodeData);
    LOCAL.Barcode.setDrawingText(false);
    LOCAL.Barcode.setDrawingQuietSection(false);
    LOCAL.Barcode.setBarWidth(1);
    LOCAL.Barcode.setBarHeight(30);
    LOCAL.BarcodeImageHandler = CreateObject("java", "net.sourceforge.barbecue.BarcodeImageHandler");
    LOCAL.BarcodeBufferedImage = LOCAL.BarcodeImageHandler.getImage(LOCAL.Barcode);
    LOCAL.BarcodeImage = ImageNew(LOCAL.BarcodeBufferedImage);
    LOCAL.BarcodeImagePath =
        "C:\temp_\barcode-" & LOCAL.BarcodeData & ".jpg";
    ImageWrite(LOCAL.BarcodeImage, LOCAL.BarcodeImagePath, 1);
</cfscript>
<cfimage action="writeToBrowser" source="#LOCAL.BarcodeImagePath#" />

看起來圖像的條寬比示例大。 將條寬設置為1像素。 通過添加LOCAL.Barcode.setBarWidth(1); 在生成條形碼之前。

<cfscript>
  LOCAL.BarcodeData = "10047846";
  LOCAL.BarcodeFactory = CreateObject("java", "net.sourceforge.barbecue.BarcodeFactory");
  LOCAL.Barcode = LOCAL.BarCodeFactory.createCode128(LOCAL.BarcodeData);
  LOCAL.Barcode.setBarWidth(1); // decrease the width of the bars
  LOCAL.Barcode.setBarHeight(50); // if you want a taller barcode like the examples
  LOCAL.BarcodeImageHandler = CreateObject("java", "net.sourceforge.barbecue.BarcodeImageHandler");
  LOCAL.BarcodeBufferedImage = LOCAL.BarcodeImageHandler.getImage(LOCAL.Barcode);
  LOCAL.BarcodeImage = ImageNew(LOCAL.BarcodeBufferedImage);
  LOCAL.BarcodeImagePath = gettempDirectory()& "\barcode-" & LOCAL.BarcodeData & ".jpg";
ImageWrite(LOCAL.BarcodeImage, LOCAL.BarcodeImagePath, 1);
</cfscript>

我用條形碼掃描儀掃描它,所有三個圖像讀取相同的字符串“10047846”。 對於條形碼,我使用CFBarbecue( http://cfbarbecue.riaforge.org/ ),一個ColdFusion燒烤包裝。 使用相同的字符串,下面是我能夠使用CFBarbecue生成的圖像。

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM