Jump to content

Recommended Posts

Posted
In an application using the VCL TCanvas to generate a BarCode with a TImage component (Image1.Canvas), like the example below..
 
There is a property in TUniImage Canvas, and has no equivalent method TUniCanvas the TCanvas.Polygon.
 
How can I adapt the example below to UniGui?
 
procedure TMainForm.CriaCodigo(Cod: string; Imagem: TCanvas);
const
  digitos: array ['0' .. '9'] of string[5] = ('00110', '10001', '01001',
    '11000', '00101', '10100', '01100', '00011', '10010', '01010');
var
  Numero: string;
  Cod1: array [1 .. 1000] of Char;
  Cod2: array [1 .. 1000] of Char;
  Codigo: array [1 .. 1000] of Char;
  Digito: string;
  c1, c2: Integer;
  X, Y, z, h: LongInt;
  a, b, c, d: TPoint;
  I: Boolean;
begin
  Numero := Cod;
  for X := 1 to 1000 do
  begin
    Cod1[X] := #0;
    Cod2[X] := #0;
    Codigo[X] := #0;
  end;
  c1 := 1;
  c2 := 1;
  X := 1;
  for Y := 1 to Length(Numero) div 2 do
  begin
    Digito := digitos[Numero[X]];
    for z := 1 to 5 do
    begin
      Cod1[c1] := Digito[z];
      inc(c1);
    end;
    Digito := digitos[Numero[X + 1]];
    for z := 1 to 5 do
    begin
      Cod2[c2] := Digito[z];
      inc(c2);
    end;
    inc(X, 2);
  end;
  Y := 5;
  Codigo[1] := '0';
  Codigo[2] := '0';
  Codigo[3] := '0';
  Codigo[4] := '0'; 
  for X := 1 to c1 - 1 do
  begin
    Codigo[Y] := Cod1[X];
    inc(Y);
    Codigo[Y] := Cod2[X];
    inc(Y);
  end;
  Codigo[Y] := '1'; 
  inc(Y);
  Codigo[Y] := '0';
  inc(Y);
  Codigo[Y] := '0';
  Imagem.Pen.Width := 1;
  Imagem.Brush.Color := ClWhite;
  Imagem.Pen.Color := ClWhite;
  a.X := 1;
  a.Y := 0;
  b.X := 1;
  b.Y := 50;
  c.X := 2000;
  c.Y := 50;
  d.X := 2000;
  d.Y := 0;
  Imagem.Polygon([a, b, c, d]);
  Imagem.Brush.Color := ClBlack;
  Imagem.Pen.Color := ClBlack;
  X := 0;
  I := True;
  for Y := 1 to 1000 do
  begin
    if Codigo[Y] <> #0 then
    begin
      if Codigo[Y] = '0' then
        h := 1
      else
        h := 3;
      a.X := X;
      a.Y := 0;
      b.X := X;
      b.Y := 50;
      c.X := X + h - 1;
      c.Y := 50;
      d.X := X + h - 1;
      d.Y := 0;
      if I then
        Imagem.Polygon([a, b, c, d]);
      I := not(I);
      X := X + h;
    end;
  end;
end;

// here call the procedure
CriaCodigo(cdsCOD_BAR.FieldByName('COD_BARRA').AsString, Image1.Canvas);

 

 

Posted

 

TUniImage.BitmapCanvas 

TUniImage.BitmapCanvas ? 

 

Not Compiled. Error E2003: Undeclared indentifier "BitmapCanvas"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...