Home QR Codes by DelphiZXingQRCode are not always decodable, how to implement the solution?
Reply: 1

QR Codes by DelphiZXingQRCode are not always decodable, how to implement the solution?

Peter Meier
1#
Peter Meier Published in 2018-01-09 13:38:40Z

The question QR Codes encoded by DelphiZXingQRCode not decodable with ErrorCorrectionLevel > Low 1 is solved. I have exactly the same problem, but I cannot implement the solution, because there are missing sections: The method GenerateQRCode is not described. It is not clear to me, where the function TErrorCorrectionLevel.GetBits has to be used. The declaration of the variable fOrdinal is not clear. I tried several times to guess the missing sections of the solution.

Peter Meier
2#
Peter Meier Reply to 2018-01-10 22:18:10Z

Solved: Missing code for the merging:

(* Start Declaration of fOrdinal; Constructor added, use of GetBits *)
TErrorCorrectionLevel = class
private
  fOrdinal: Integer;
  function GetBits:Integer;
public
  constructor Create(ordinalValue: Integer); reintroduce;
  procedure Assign(Source: TErrorCorrectionLevel);
  property Bits: Integer read GetBits;
end;
(* End Declaration of fOrdinal; Constructor added, use of GetBits *)


(* Start of modified GenerateQRCode, Level is taken from Input-Parameter *)
function GenerateQRCode(const Input: WideString; EncodeOptions: Integer; AErrorCorrectionLevel:Integer): T2DBooleanArray;
var
  Encoder: TEncoder;
  Level: TErrorCorrectionLevel;
  QRCode: TQRCode;
  X: Integer;
  Y: Integer;
begin
  Level := TErrorCorrectionLevel.Create(AErrorCorrectionLevel);
  Encoder := TEncoder.Create;
  QRCode := TQRCode.Create;
  try
    Encoder.Encode(Input, EncodeOptions, Level, QRCode);
    if (Assigned(QRCode.FMatrix)) then
    begin
      SetLength(Result, QRCode.FMatrix.FHeight);
      for Y := 0 to QRCode.FMatrix.FHeight - 1 do
      begin
        SetLength(Result[Y], QRCode.FMatrix.FWidth);
        for X := 0 to QRCode.FMatrix.FWidth - 1 do
        begin
          Result[Y][X] := QRCode.FMatrix.Get(Y, X) = 1;
        end;
      end;
    end;
  finally
    QRCode.Free;
    Encoder.Free;
    Level.Free;
  end;
end;
(* End of modified GenerateQRCode, Level is taken from Input-Parameter *)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307355 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO