3

Barbecue Barcode Libraryに問題があります。シンプルな 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から得たものです:

ここに画像の説明を入力

現在、サイズ変更、スケーリングなどの問題はありません。しかし、バーベキューで生成された画像が大きく異なることは簡単にわかります。最初の数本のバーを見てください。

なぜこうなった?これはバーベキューのバグですか、それとも何か間違っていますか?

4

3 に答える 3

1

これ自体が「答え」であるかどうかはわかりませんが、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#" />
于 2015-02-04T22:40:51.263 に答える
0

画像のバーの幅が例よりも大きいようです。バーの幅を 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>
于 2015-02-04T22:05:15.667 に答える
0

バーコード スキャナーでスキャンしたところ、3 つの画像すべてで同じ文字列「10047846」が読み取られました。バーコードには、Barbecue の ColdFusion ラッパーであるCFBarbecue ( http://cfbarbecue.riaforge.org/ ) を使用します。同じ文字列を使用して、CFBarbecue を使用して生成できた画像を以下に示します。

ここに画像の説明を入力

于 2015-02-04T22:18:00.177 に答える