【记录一下】修正lazarus fr报表控件在龙芯电脑不能使用QRcode的Bug

发布时间 2023-05-21 16:38:40作者: 秋·风

近日海南朋友使用fr控件时发现不能在报表插入QRCode和PDF417等二维码,经跟踪发现只需将frxBarcodePDF417.pas第1592行

A := TInt(ERROR_LEVEL[errorLevel]);

改为:

A := @(ERROR_LEVEL[errorLevel]);

就可以正常插入QRCode等二维码了,如果你使用过程也遇到同样问题可参考一下。
使用环境:
lazarus 2.3
FPC 3.31
CPU:Loongarch64
OS:统信专业版

procedure TfrxBarcodePDF417.CalculateErrorCorrection( dest : integer);
var
    A : TInt;
    ALength,e,k,t1,t2,t3, LastE : integer;
begin
    if (errorLevel < 0) or ( errorLevel > 8) then
        errorLevel := 0;
    A := @(ERROR_LEVEL[errorLevel]); //2023.05.21 LBZ修正QRCode等不能使用的Bug
    //A := TInt(ERROR_LEVEL[errorLevel]);
    Alength := 2 shl errorLevel;
    for k := 0 to Alength-1 do
        codewords[dest + k] := 0;
    lastE := Alength - 1;
    for k := 0 to lenCodewords-1 do
    begin
        t1 := codewords[k] + codewords[dest];
        for e := 0 to lastE do
        begin
            t2 := (t1 * A[lastE - e]) mod _MOD;
            t3 := _MOD - t2;
            if e = LastE then
                codewords[dest + e] := t3 mod _MOD
            else
                codewords[dest + e] := ((codewords[dest + e + 1]) + t3) mod _MOD;
        end;
    end;
    for k := 0 to Alength- 1 do
        codewords[dest + k] := (_MOD - codewords[dest + k]) mod _MOD;

end;