Search code examples
firemonkeyc++builderc++builder-10.3-rio

Reposition image in TImageViewer


i'm building an FMX app for iOS, it has a TImageViewer on a TPanel with the TImageVieweraligned to Contents. I load a bitmap from file into the TImageViewer and i can then pan around and zoom in/out on the image. Works fine.

What i want now is a button click event to reposition the left edge of the image on the left edge of the TPanel so it looks like the top image below.

Here is example of what it looks like when first loaded:

enter image description here

Here it is after i have panned it around:

enter image description here

I've searched and experimented all day but i just can't get it. I tried reloading the bitmap file but did nothing. Any suggestions?

thanks, russ


Solution

  • Found a way based on this delphi question. Note that ImageMap is the name of my TImageViewer on Form1.

    TPointF myOffset;
    myOffset = Form1->ImageMap->ViewportPosition; // this is (0,0) before the image is panned around, non-zero otherwise
    Form1->ImageMap->ScrollBy(myOffset.X, myOffset.Y) ;