Hello programmers,
I have a simple form with 4 buttons a scrollbox and an image in the scrollbox.
On creationtime a picture is loaded in a bitmap and showed in the viewport aka scollbox-image. Perfekt!
When I click the Zoom+ button the image is enlarged *2, and the bitmap is copied to the image.
Now the problem is the image is bigger then what I expected it to be and a part right and below is never visable by scrolling.
When clicked on the Zoom- button after creation, the image is half the size but also a quarter size is visable in the upper-left corner.
When I click the scollbars there seems to be a double action. The handle is clicked right, the handle goes right and then goes left a bit.
Also the image seems to be updated twice.
Clicking twice or more the same action, it becomes even more too big, or too small..
Zoom- would give even 3 or 4 pictures over each other.
So, Lines go well, coloring goes well. But problems with copying bitmap onto the Image in the Scrollbox.
b.t.w. Image1.Autosize / Proportional == False, Strech == True(needed to view with the scollbars)
I dont know what you need to help me out, but I have the zoom routines here and it is on Linux Mint.:
procedure TForm1.DoZoomInClick(Sender: TObject);
var
W,H: Integer;
begin
W := Image1.Width*2;
H := Image1.Height*2;
TgtRect := Rect(0,0,W,H);
// ScrRect == Size of Bitmap
Image1.Height := H;
Image1.Width := W;
// After the copy, the bitmap is sized in Image1.
// Scollbars can be used to view Image-parts outside viewport.
Image1.Canvas.CopyRect(TgtRect,Bitmap.Canvas,SrcRect);
Debug.Text:=Format('Img W: %d, H: %d , Sbx W: %d, H: %d , Bm W: %d, H %d' ,
[ Image1.Width,Image1.Height,ScrollBox1.Width,ScrollBox1.Height,Bitmap.Width, Bitmap.Height]);
end;
procedure TForm1.DoZoomOutClick(Sender: TObject);
var
W,H: Integer;
begin
W := Round(Image1.Width*0.5);
H := Round(Image1.Height*0.5);
TgtRect := Rect(0,0,W,H);
// ScrRect == Size of Bitmap
Image1.Height := H;
Image1.Width := W;
// After the copy, the bitmap is sized in Image1.
// Scollbars can be used to view Image-parts outside viewport.
Image1.Canvas.CopyRect(TgtRect,Bitmap.Canvas,SrcRect);
Debug.Text:=Format('Img W: %d, H: %d , Sbx W: %d, H: %d , Bm W: %d, H %d' ,
[ Image1.Width,Image1.Height,ScrollBox1.Width,ScrollBox1.Height,Bitmap.Width, Bitmap.Height]);
end;