Hello!
I put images onto a ScrollBox and I would like copy pieces from those onto an other image with
CopyRect() function. But when I click on the edge of these images on the ScrollBox, then the small image contains the pieces of scrollbar instead the other parts of the image, which sticking out from ScrollBox.
Then, when I scroll away the image,
CopyRect() produces white rectangles instead of right image. So, how big is the canvas of an image? Is it equal only with its visible area? Or how can I access to its whole parts when I scroll it back and forth?
I create images with this procedure:
procedure TForm1.buttonImageAdClick(Sender: TObject);
begin
if (imageOpener.Execute) and (sourcetiles<255) then
begin
tileimage[sourcetiles+1]:=TImage.Create(Self);
tileimage[sourcetiles+1].Parent:=placeofTiles;
tileimage[sourcetiles+1].Autosize:=true;
tileimage[sourcetiles+1].Transparent:=true;
tileimage[sourcetiles+1].Picture.LoadFromFile(imageOpener.FileName);
tileimage[sourcetiles+1].OnMouseUp:=@clickontile;
tileimage[sourcetiles+1].Left:=0;
if sourcetiles=0 then
begin
tileimage[sourcetiles+1].Top:=0;
actualtile:=1;
end
else
tileimage[sourcetiles+1].Top:=tileimage[sourcetiles].Top+tileimage[sourcetiles].height+2;
inc(sourcetiles);
end;
end;
and this is where I copy small images from the tiles:
procedure TForm1.clickontile(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i: byte;
begin
for i:=0 to sourcetiles-1 do
begin
if (X>=tileimage[i+1].Left) and (X<=tileimage[i+1].Left+tileimage[i+1].width) and (Y>=tileimage[i+1].Top) and (Y<=tileimage[i+1].Top+tileimage[i+1].height) then
begin
if copytileexists=false then
begin
copytile:=TImage.Create(Self);
copytile.Parent:=self;
copytile.Left:=X;//+tilePlace.HorzScrollbar.position;
copytile.Top:=Y;//+tilePlace.VertScrollbar.position;
copytile.width:=tilewidth;
copytile.height:=tileheight;
end;
copytile.canvas.copyrect(Rect(0,0,tilewidth,tileheight),tileimage[i+1].canvas,Rect(X,Y,X+tilewidth,Y+tileheight));
copytileexists:=true;
Break;
end;
end;
end;