0
votes

On the exemple below, you can see that the application draws two bitmaps (Yellow and Blue) of 256x256 pixels side by side horizontally (0-255 and 256-511) on a red backgroud rectangle (512x260). There is no scaling. The question is, why a vertical pixels line of the background (red) can be viewed between the two ? Delphi 10.1

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
    System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
  FMX.Controls.Presentation, FMX.StdCtrls;

type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    procedure PaintBox1Paint(Sender: TObject; Canvas: TCanvas);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    bm1: TBitmap;
    bm2: TBitmap;
    br: TStrokeBrush;
    bShift: Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.FormCreate(Sender: TObject);
begin
  bm1 := TBitmap.Create(256, 256);
  if bm1.Canvas.BeginScene then
    try
      bm1.Canvas.Fill.Color := TAlphaColorRec.Yellow;
      bm1.Canvas.FillRect(RectF(0, 0, bm1.Width, bm1.Height
        ),
        0, 0, AllCorners, 1);
    finally
      bm1.Canvas.EndScene;
    end;
  bm2 := TBitmap.Create(256, 256);
  if bm2.Canvas.BeginScene then
    try
      bm2.Canvas.Fill.Color := TAlphaColorRec.Blue;
      bm2.Canvas.FillRect(RectF(0, 0, bm2.Width, bm2.Height
        ),
        0, 0, AllCorners, 1);
    finally
      bm2.Canvas.EndScene;
    end;

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  bm1.Free;
  bm2.Free;
end;

procedure TForm1.PaintBox1Paint(Sender: TObject; Canvas: TCanvas);
var
  RecPic: TRectF;
  RecCanvas: TRectF;
  RecCanvas2: TRectF;
begin
  if Canvas.BeginScene then
    try
      Canvas.Fill.Color := TAlphaColorRec.White;
      Canvas.FillRect(RectF(0, 0, PaintBox1.Width, PaintBox1.Height
        ),
        0, 0, AllCorners, 1);

      Canvas.Fill.Color := TAlphaColorRec.Red;
      Canvas.FillRect(RectF(0, 0, 511, 260
        ),
        0, 0, AllCorners, 1);
      RecPic := RectF(0, 0, 255, 255);
      RecCanvas := RectF(0, 0, 255, 255);
      Canvas.DrawBitmap(bm1, RecPic, RecCanvas, 1);

      RecCanvas2 := RectF(256, 0, 511, 255);
      Canvas.DrawBitmap(bm2, RecPic, RecCanvas2, 1);
    finally
      Canvas.EndScene;
    end;
end;

end.

Thanks a lot

1

1 Answers

0
votes

You must use RecCanvas as RectF(0, 0, 256, 256) and RecCanvas2 as RectF(256, 0, 512, 256), because right and bottom borders are excluded from bitmap drawing area