0

I try to rewrite an FMX project in VCL.

Code for QR-code drawing in FMX:

for Column := 0 to QRCode.Columns - 1 do
begin
  if QRCode.IsBlack[Row, Column] then
    QRCodeBitmap.ClearRect(TRectF.Create(PointF(Column, Row) * Scale,
      Scale, Scale), TAlphaColors.Black);
end;

How to replace QRCodeBitmap.ClearRect() in VCL?

I try like this:

if (QRCode.IsBlack[Row, Column]) then
begin
  QRCodeBitmap.Canvas.Pixels[Column, Row] := clBlack;
end else
begin
  QRCodeBitmap.Canvas.Pixels[Column, Row] := clWhite;
end; 

but it does not work like I want.

0

1 Answer 1

1

The TBitmap.ClearRect() method in FMX fills a rectangular area with a color.

In VCL, you can do the same thing using the TBitmap.Canvas.FillRect() method, where the fill color is specified in the TBitmap.Canvas.Brush.Color property, eg:

for Column := 0 to QRCode.Columns - 1 do
begin
  if QRCode.IsBlack[Row, Column] then
  begin
    QRCodeBitmap.Canvas.Brush.Color := clBlack;
    QRCodeBitmap.Canvas.FillRect(TRect.Create(Point(Column * Scale, Row * Scale),
      Scale, Scale));
  end;
end;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.