由DelphiZXingQRCode编码的QR码不可使用ErrorCorrectionLevel进行解码>;低

由DelphiZXingQRCode编码的QR码不可使用ErrorCorrectionLevel进行解码>;低,delphi,qr-code,zxing,Delphi,Qr Code,Zxing,我正在使用这个德尔福单位。我被迫使用这个旧的Delphi实现,所以不要问这个问题: 它产生的QR码可以被任何解码器很好地解码,只要我将纠错级别保持在“低”。如果我提高纠错级别,生成的代码将无法被我迄今为止尝试的任何解码器解码。但我被迫(按照一个标准)使用一个中等的纠错级别,不能多也不能少 然而,目前尚不清楚如何提高纠错水平(ecl)。我假设它是在第3491行的文件DelphiZXingQRCode中硬编码的:Level.FBits:=1。我找到了一些表示ECL的十六进制数的信息,但现在找不到。

我正在使用这个德尔福单位。我被迫使用这个旧的Delphi实现,所以不要问这个问题:

它产生的QR码可以被任何解码器很好地解码,只要我将纠错级别保持在“低”。如果我提高纠错级别,生成的代码将无法被我迄今为止尝试的任何解码器解码。但我被迫(按照一个标准)使用一个中等的纠错级别,不能多也不能少

然而,目前尚不清楚如何提高纠错水平(ecl)。我假设它是在第3491行的文件DelphiZXingQRCode中硬编码的:Level.FBits:=1。我找到了一些表示ECL的十六进制数的信息,但现在找不到。但我尝试将这些十六进制数作为位,QR码上的ecl位也相应地改变了。所以我假设十六进制数是正确的(1=低,0=中,2=高,3=四分位数)

下面是Level.FBits:=2的QRcode示例,这意味着我希望ecl为“高”。内容是“你好,世界”。中间的交叉图像是我必须执行的标准的一部分,所以不要问这个问题。


有人知道怎么解决这个问题吗?我试着…嗯…我试着理解代码,但是太多了。我就是修不好。如果我找不到其他人来修理,我就得…找到另一个解决办法。这将是一个问题。

已解决。请参阅下面的代码。方法GenerateQRCode()现在需要ErrorCorrectionLevel的参数:整数0-3。似乎有效。我不得不删除一些未更改的行,因为文件太大,无法执行StackOverflow。合并你自己

    unit DelphiZXingQRCode;

    // ZXing QRCode port to Delphi, by Debenu Pty Ltd
    // www.debenu.com

    // Original copyright notice
    (*
     * Copyright 2008 ZXing authors
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     *)

    interface

    type
      TQRCodeEncoding = (qrAuto, qrNumeric, qrAlphanumeric, qrISO88591, qrUTF8NoBOM, qrUTF8BOM);
      T2DBooleanArray = array of array of Boolean;

      TDelphiZXingQRCode = class
      protected
        FData: WideString;
        FRows: Integer;
        FColumns: Integer;
        FEncoding: TQRCodeEncoding;
        FQuietZone: Integer;
        FElements: T2DBooleanArray;
        FErrorCorrectionLevel: integer;
        procedure SetEncoding(NewEncoding: TQRCodeEncoding);
        procedure SetData(const NewData: WideString);
        procedure SetQuietZone(NewQuietZone: Integer);
        procedure SetErrorCorrectionLevel(value: integer);
        function GetIsBlack(Row, Column: Integer): Boolean;
        procedure Update;
      public
        constructor Create;
        property Data: WideString read FData write SetData;
        property Encoding: TQRCodeEncoding read FEncoding write SetEncoding;
        property ErrorCorrectionLevel: integer read fErrorCorrectionLevel write SetErrorCorrectionLevel;
        property QuietZone: Integer read FQuietZone write SetQuietZone;
        property Rows: Integer read FRows;
        property Columns: Integer read FColumns;
        property IsBlack[Row, Column: Integer]: Boolean read GetIsBlack;
      end;

    implementation

    uses
      SysUtils,
      contnrs, Math, Classes;

    type
      TByteArray = array of Byte;
      T2DByteArray = array of array of Byte;
      TIntegerArray = array of Integer;

    // File too large for Stackoverflow: Deleted unchanged lines.

    { TErrorCorrectionLevel }

    procedure TErrorCorrectionLevel.Assign(Source: TErrorCorrectionLevel);
    begin
      Self.fOrdinal := Source.FOrdinal;
    end;

    constructor TErrorCorrectionLevel.Create(ordinalValue: integer);
    begin

      fOrdinal:=0;
      if (ordinalValue >= 0) and (ordinalValue <=3) then
        fOrdinal:=ordinalValue;
    end;

    function TErrorCorrectionLevel.GetBits: integer;
    begin
      if fOrdinal = 0 then  // level L
        result:=1
      else
      if fOrdinal = 1 then  // level M
        result:=0
      else
      if fOrdinal = 2 then  // level Q
        result:=3
      else
      if fOrdinal = 3 then  // level H
        result:=2
      else
        result:=1;
    end;


    // File too large for Stackoverflow: Deleted unchanged lines.

    procedure TDelphiZXingQRCode.SetErrorCorrectionLevel(value: integer);
    begin
      if (value < 0) or (value > 3) then
        raise Exception.Create('invalid error correction value. must be in range 0..3.');

      if value <> fErrorCorrectionLevel then
      begin
        FErrorCorrectionLevel:=value;
        Update;
      end;
    end;

    procedure TDelphiZXingQRCode.SetQuietZone(NewQuietZone: Integer);
    begin
      if ((FQuietZone <> NewQuietZone) and (NewQuietZone >= 0) and (NewQuietZone <= 100)) then
      begin
        FQuietZone := NewQuietZone;
        Update;
      end;
    end;

    procedure TDelphiZXingQRCode.Update;
    begin
      FElements := GenerateQRCode(FData, Ord(FEncoding), FErrorCorrectionLevel);
      FRows := Length(FElements) + FQuietZone * 2;
      FColumns := FRows;
    end;
    end.
单位编码;
//德本私人有限公司提供的德尔福ZXing QRCode港口
//www.debenu.com
//版权声明原件
(*
*版权所有2008 ZXing作者
*
*根据Apache许可证2.0版(以下简称“许可证”)获得许可;
*除非遵守许可证,否则不得使用此文件。
*您可以通过以下方式获得许可证副本:
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*除非适用法律要求或书面同意,软件
*根据许可证进行的分发是按“原样”进行分发的,
*无任何明示或暗示的保证或条件。
*请参阅许可证以了解管理权限和权限的特定语言
*许可证下的限制。
*)
接口
类型
TQRCodeEncoding=(qrAuto、qrNumeric、qrAlphanumeric、qrISO88591、qrUTF8NoBOM、qrUTF8BOM);
T2DBooleanArray=布尔数组的数组;
TDelphiZXingQRCode=类
受保护的
FData:宽字符串;
FRows:整数;
FColumns:整数;
fencodeding:tqrcodecoding;
FQuietZone:整数;
元素:T2DBooleanArray;
铁磁校正级别:整数;
过程SetEncoding(NewEncoding:TQRCodeEncoding);
程序SetData(const NewData:WideString);
过程SetQuietZone(NewQuietZone:Integer);
过程SetErrorCorrectionLevel(值:整数);
函数GetIsBlack(行、列:整数):布尔;
程序更新;
公众的
构造函数创建;
属性数据:宽字符串读取FData写入SetData;
属性编码:TQRCodeEncoding读写SetEncoding;
属性ErrorCorrectionLevel:integer读取fErrorCorrectionLevel写入设置ErrorCorrectionLevel;
属性QuietZone:整数读取FQuietZone写入SetQuietZone;
属性行:整数读取FRows;
属性列:整数读取FColumns;
属性IsBlack[行、列:整数]:布尔读取GetIsBlack;
结束;
实施
使用
SysUtils,
内容、数学、课程;
类型
TByteArray=字节数组;
T2DByteArray=字节数组的数组;
TinteGrarray=整数数组;
//文件太大,无法堆叠溢出:已删除未更改的行。
{terrocorrectionlevel}
程序TerroCorrectionLevel.Assign(来源:TerroCorrectionLevel);
开始
Self.fOrdinal:=Source.fOrdinal;
结束;
构造函数terrocorrectionlevel.Create(序数值:整数);
开始
fOrdinal:=0;
如果(序数值>=0)和(序数值3),则
引发异常。Create('错误更正值无效。必须在范围0..3'内');
如果值为铁校正水平,则
开始
铁校正水平:=数值;
更新;
结束;
结束;
过程TDelphiZXingQRCode.SetQuietZone(NewQuietZone:Integer);
开始

如果((FQuietZone NewQuietZone)和(NewQuietZone>=0)和(NewQuietZone),它可以工作,但您必须自己猜测一些更改。无论如何,感谢修复,您可以将其发送到上游吗?