这个是自己项目在使用的,所以带有些业务功能的代码。

逻辑上使用的大多是 mouseup ,MouseMove,Mousedown。使用recttangle容器实现滑动。网上有这个下载demo。

另外移动端要注意线程的异步同步的控制。

unit UShowPictureZoomIn;

interface

uses
  System.SysUtils,
  System.Types,
  System.UITypes,
  System.IOUtils,
  System.Classes,
  System.Variants,
  System.Messaging ,
  System.Generics.Collections,
  FMX.Types,
  FMX.Graphics,
  FMX.Controls,
  FMX.Forms,
  FMX.Dialogs,
  FMX.StdCtrls,
  FMX.Objects,
  FMX.Effects,
  FMX.Ani,
  FMX.Controls.Presentation,
  FMX.Layouts,DRCommonEvent,
  DRFormClass,PublicVariables,ParentFrm,UDM,MSFileCLass,
  GetData,Common,Datasnap.DBClient,DataRec,CDSHelper ,
  {$IFNDEF MSWINDOWS}
  FMX.Gestures,
  {$ENDIF}
  FMX.Edit;

type
  //  TArray   =  array of string;
  TArrays  =  array of array of string;
  TFrmShowPictureZoomIn = class(TParentform)
    LayoutContainer: TLayout;
    Image1: TImage;
    Image2: TImage;
    RectBottom: TRectangle;
    AChkType: TCheckBox;
    lblSelectOK: TLabel;
    RectTop: TRectangle;
    ImgReturn: TImage;
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
    //
    procedure RectOnMouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Single);
    procedure RectOnMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Single);
    procedure RectOnMouseUP(Sender: TObject; Button: TMouseButton;Shift : TShiftState; X, Y: Single);
    procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo;
      var Handled: Boolean);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Single);
    procedure lblSelectOKClick(Sender: TObject);
    procedure ImgReturnClick(Sender: TObject);
    procedure FormTap(Sender: TObject; const Point: TPointF);
    procedure RectTopClick(Sender: TObject);
  private
    { Private declarations }
     {$IFNDEF MSWINDOWS}
     GestureManager1  : TGestureManager ;
     {$ENDIF}
     ARectOK         : TRectangle;
     ARectCancel     : TRectangle ;
     ARectChk        : TRectangle ;
     ARectIsCreate   : boolean ;
     AImage          : Array of TImage ;
     ARect           : Array of TRectangle ;
    //
     FLastPosition   : TPointF;
     FLastDIstance   : integer ;
     FOriginalWidth  : Array of Single ;
     FOriginalHeight : Array of Single ;
     FOriginalX      : Array of single ;
     FOriginalY      : Array of Single ;
     FZoomWidth      : Single ;
     FZoomHeight     : Single ;
    //
    BMSCarrierObject_ID:string;
   // AImgGuIDRelationship:TImgGuIDRelationship;
    ArrayOfGuID    :TArrays;
    firstHit  :  integer;
    AGuIDlist:Tstringlist;
   // ArrayOfGuID    :array of array of string;

FBitmapList    : TList<TBitmap>;

FImgListPath   : TList<string>;
    FCurrentIndex  : integer ;
    PageCount,PageCountA      : integer ;
    pageIndex      : Integer;
    tapDownPos     : TPointF;
    tapDownPosF    : TPointF;
    FX             : single ;

tapIsDown: Boolean;  // This is needed, since the tap can happend outside control and then moved inside it to release
    procedure  ScrollMainView(page: Integer);
    procedure  InitFormInfo ;
    //
    procedure  InitImageList();
    procedure  InitCurrentImage ;
    procedure  InitFormInfoA ;
    //
    procedure  InitImageListPath ;
    procedure  InitCurrentImgPath ;
    //
    procedure  InitImageStrPath ;
    Procedure  InitCurrentPath ;

procedure  ARectCancelOnClick(Sender :TObject);
    procedure  ARectOnClick(Sender :TObject);
    procedure  LblOkClick(Sender: TObject);

procedure  LoadImgGuIDInfo;   //下载小图guid和大图guid对应表    暂时不用
    procedure  LoadZoomImg(AIndex:integer);
  public
    { Public declarations }
    //缩约图list,缩约图idlist,点击的第几张图,载体id,缩约图和原图对应的id 2维表
    class Procedure  ShowForm(AList:TList<TBitmap>;BGuIDlist:Tstringlist;AIndex
                      :integer;AMSCarrierObject_ID:string; AArrayOfGuID:TArrays); overload;
    class Procedure  ShowForm(AListPath : TList<string> ; AIndex :Integer );overload;

end;

var
  FrmShowPictureZoomIn: TFrmShowPictureZoomIn;

implementation

{$R *.fmx}

procedure TFrmShowPictureZoomIn.ARectCancelOnClick(Sender: TObject);
begin
  TDRForm.Create(TFrmShowPictureZoomIn).Release ;
end;

procedure TFrmShowPictureZoomIn.ARectOnClick(Sender: TObject);
var
  ABitmap : TBitmap ;
  AList   : TList<TBitmap>;
begin
  if Sender is TRectangle then
  begin
     try
        AList   := TList<TBitmap>.Create;
        ABitmap := TBitmap.Create;
        ABitmap.Assign(AImage[pageindex].bitmap);
        if AChkType.IsChecked <> true then
           ABitmap.CreateThumbnail(40,40);
        AList.Add(ABitmap);
        TMessageManager.DefaultManager.SendMessage(self,TImageCallBack.Create(AList));
        //image2.Bitmap.Assign(AImage[pageindex-1].bitmap);
     finally
       ABitmap.DisposeOf ;
     end;
  end;

end;

procedure TFrmShowPictureZoomIn.FormCreate(Sender: TObject);
begin
  pageIndex := 0;
  tapIsDown := false;
  LayoutContainer.Position.Y := 60;
  ARectIsCreate := false;
end;

procedure TFrmShowPictureZoomIn.FormGesture(Sender: TObject;
  const EventInfo: TGestureEventInfo; var Handled: Boolean);
var
  LObj   : IControl;
  LImage : TImage;
  LImageCenter : TPointF;
  ATag   : integer ;
begin
   INHERITED;
  {$IFNDEF MSWINDOWS}
   if Sender is TImage then
      ATag := TImage(Sender).Tag ;
   if Sender is TRectangle then
      ATag := TRectangle(Sender).Tag;
  if EventInfo.GestureID = igiZoom then
  begin
    tapIsDown := false;
    LObj := Self.ObjectAtPoint(ClientToScreen(EventInfo.Location));
    if LObj is TImage then
    begin
      if (not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags)) and
        (not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags)) then
      begin
        LImage := TImage(LObj.GetObject);
        LImageCenter := LImage.Position.Point + PointF(LImage.Width / 2,
                        LImage.Height / 2);

LImage.Width := LImage.Width + (EventInfo.Distance - FLastDistance);

LImage.Height := LImage.Height + (EventInfo.Distance - FLastDistance);

LImage.Position.X := LImageCenter.X - LImage.Width / 2;
        LImage.Position.Y := LImageCenter.Y - LImage.Height / 2;
        //

if LImage.Width < FOriginalWidth[PageIndex] then
        begin
           FZoomWidth := LImage.Width ;
        end;
        if LImage.height < FOriginalHeight[PageIndex] then
        begin
           FZoomheight := LImage.height ;
        end;
      end;
      FLastDistance := EventInfo.Distance;
      Handled := true ;
    end;
  end;
  {$ENDIF}
end;

procedure TFrmShowPictureZoomIn.FormMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin

if FZoomWidth< FOriginalWidth[PageIndex] then
     begin
        AImage[PageIndex].Position.X := FOriginalX[PageIndex];
        AImage[PageIndex].Position.Y := FOriginalY[PageIndex] ;
        AImage[PageIndex].Width      := FOriginalWidth[PageIndex] ;
        AImage[PageIndex].Height     := FOriginalHeight[PageIndex] ;
     end;
end;

procedure TFrmShowPictureZoomIn.FormResize(Sender: TObject);
var
  i :integer ;
begin
  LayoutContainer.Height := Self.ClientHeight;
  LayoutContainer.Width  := self.ClientWidth ;
  RectTop.Width := trunc(self.ClientWidth / 3 );
  if ARectIsCreate then
  begin

if Assigned(FBitmapList) then
        for i :=0  to FBitmapList.Count -1  do
        begin
            ARect[i].Width := self.ClientWidth ;
            if i>0 then
              ARect[i].Position.X :=ARect[i-1].Width *I;
           ScrollMainView(FCurrentIndex);
        end;
     if Assigned(FImgListPath) then
        for i :=0  to FImgListPath.Count -1  do
        begin
            ARect[i].Width := self.ClientWidth ;
            if i>0 then
              ARect[i].Position.X :=ARect[i-1].Width *I;
           ScrollMainView(FCurrentIndex);
        end;
  end;
end;

procedure TFrmShowPictureZoomIn.FormTap(Sender: TObject; const Point: TPointF);
begin
  TDRForm.Create(self).Release ;
end;

procedure TFrmShowPictureZoomIn.ImgReturnClick(Sender: TObject);
begin
  TDRForm.Create(self).Release ;
end;

procedure TFrmShowPictureZoomIn.InitCurrentImage;
begin
  ScrollMainView(FCurrentIndex);
end;

procedure TFrmShowPictureZoomIn.InitCurrentImgPath;
begin

end;

procedure TFrmShowPictureZoomIn.InitCurrentPath;
begin
  TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (50 * 2) * -1, 0.5, TAnimationType.Out, TInterpolationType.Exponential);
end;

procedure TFrmShowPictureZoomIn.InitFormInfo;
begin
  //PageCount  := FBitmapList.Count  ;
  if Assigned(FBitmapList) then
     begin
       PageCount := FBitmapList.Count -1 ;
       setLength(ArrayOfGuID,FBitmapList.Count,2);
     end;
  if Assigned(FImgListPath) then
     begin
       PageCount := FImgListPath.Count -1 ;
       setLength(ArrayOfGuID,FImgListPath.Count,2);
     end;
  {$IFNDEF MSWINDOWS}
     GestureManager1  := TGestureManager.Create(SELF) ;
  {$ENDIF}
end;

procedure TFrmShowPictureZoomIn.InitFormInfoA;
begin
  PageCount := FBitmapList.Count -1 ;
end;

procedure TFrmShowPictureZoomIn.InitImageList;
var
  i : integer ;
  ARect  : Array of TRectangle ;

ARectBottom : TRectangle;
  ARectTop    : TRectangle;
  ALblOk      : TLabel ;
begin
  setLength(ARect,FBitmapList.Count);
  setLength(AImage,FBitmapList.Count);
  setLength(FOriginalWidth,FBitmapList.Count);
  setLength(FOriginalHeight,FBitmapList.Count);
  setLength(FOriginalX,FBitmapList.Count);
  setLength(FOriginalY,FBitmapList.Count);
  for i := 0 to  FBitmapList.Count-1 do
  begin
    ARect[i] := TRectangle.Create(nil);
    ARect[i].Width := self.ClientWidth ;
    ARect[i].Height := self.Height ;
    ARect[i].Parent := LayoutContainer ;
    //ARect[i].Align  := TAlignLayout.Left ;
    if i>0 then
       ARect[i].Position.X :=ARect[i-1].Width *I;
    ARect[i].Tag    := i+1 ;
    ARect[i].Fill.Color :=$FF000000;
    {$IFNDEF MSWINDOWS}
    ARect[i].Touch.GestureManager := GestureManager1 ;
    ARect[i].Touch.InteractiveGestures :=[TInteractiveGesture.Zoom,TInteractiveGesture.Pan,TInteractiveGesture.Rotate,
                                          TInteractiveGesture.TwoFingerTap,TInteractiveGesture.PressAndTap];
    ARect[i].OnGesture   := FormGesture ;
    {$ENDIF}
    ARect[i].OnMouseDown := RectOnMouseDown ;
    ARect[i].OnMouseUp   := RectOnMouseUp ;
    ARect[i].OnMouseMove := RectOnMouseMove ;

AImage[i] := FMX.Objects.TImage.Create(nil);
    AImage[i].Parent := ARect[i] ;
    AImage[i].Tag    := i+1 ;
    AImage[i].Width  := self.ClientWidth -20 ;
    AImage[i].Height := 400 ;
    AImage[i].Margins.Left :=10;
    AImage[i].Margins.Right :=10;
    AImage[i].Align :=TAlignLayout.Center ;
//    if FileExists(FBitmapList[i]) then
//    begin
//      AImage[i].Bitmap.LoadFromFile(FBitmapList[i]);
//    end
//    else
      AImage[i].Bitmap.Assign(FBitmapList[i]);

AImage[i].WrapMode :=TImageWrapMode.Stretch ;
    AImage[i].HitTest  := true ;
    AImage[i].OnMouseDown := RectOnMouseDown ;
    AImage[i].OnMouseUp   := RectOnMouseUp ;
    AImage[i].OnMouseMove := RectOnMouseMove ;

ARectBottom := TRectangle.Create(nil);
    ARectBottom.Width := self.ClientWidth ;
    ARectBottom.Height := 60;
    ARectBottom.Parent :=  ARect[i] ;
    ARectBottom.StrokeThickness := 0;
    ARectBottom.Fill.Color := $FF000000;
    ARectBottom.Opacity := 0.5 ;
    ARectBottom.Align   := TAlignLayout.Bottom ;

ARectOK  := TRectangle.Create(nil);
    ARectOK.Parent := ARectBottom ;
    ARectOK.Width  := 120;
    ARectOK.Align  := TAlignLayout.Right ;
    ARectOK.HitTest := true;
    ARectOK.Margins.Top :=8;
    ARectOK.Margins.Right :=16;
    ARectOK.Margins.Bottom :=8;
    ARectOK.Sides :=[];
    ARectOK.XRadius := 8;
    ARectOK.YRadius := 8;
    ARectOK.Fill.Color := $FF4acfd6;
    ARectOK.OnClick    := ARectOnClick ;
    ALblOk      := TLabel.Create(nil) ;
    ALblOk.Text :='选 取';
    ALblOk.AutoSize := true;
    ALblOk.Parent   :=  ARectOK ;
    ALblOk.Font.Size  := 18;
    ALblOk.FontColor  := $FFFFFF;
    ALblOk.Align    := TAlignLayout.Center ;
    ALblOk.HitTest  := false;
    //
    ARectTop := TRectangle.Create(nil);
    ARectTop.Width := self.ClientWidth ;
    ARectTop.Height := 60;
    ARectTop.Parent :=  ARect[i] ;
    ARectTop.StrokeThickness := 0;
    ARectTop.Fill.Color := $FF000000;
    ARectTop.Opacity := 0.5 ;
    ARectTop.Align   := TAlignLayout.Top ;
    //
    FOriginalWidth[i]  := AImage[i].Width ;
    FOriginalHeight[i] := AImage[i].Height ;
    FOriginalX[i]      := AImage[i].Position.X ;
    FOriginalY[i]      := AImage[i].Position.Y ;
  end;

end;

procedure TFrmShowPictureZoomIn.InitImageListPath;
var
  i : integer ;
  ARectBottom : TRectangle;
  ARectTop    : TRectangle;
  ALblOk      : TLabel ;
  ALblCancel  : TLabel ;
  AStream     : TMemoryStream ;
begin
  setLength(ARect, FImgListPath.Count);
  setLength(AImage,FImgListPath.Count);
  setLength(FOriginalWidth, FImgListPath.Count);
  setLength(FOriginalHeight,FImgListPath.Count);
  setLength(FOriginalX,FImgListPath.Count);
  setLength(FOriginalY,FImgListPath.Count);
  ARectIsCreate      := true ;
  for i := 0 to  FImgListPath.Count-1 do
  begin
    ARect[i] := TRectangle.Create(nil);
    ARect[i].Width := self.ClientWidth ;
    ARect[i].Height := self.Height;
    ARect[i].Parent := LayoutContainer ;

ARect[i].HitTest:= true ;
    if i>0 then
       ARect[i].Position.X :=ARect[i-1].Width *I;
    ARect[i].Margins.Left :=20 ;
    ARect[i].Margins.Right :=20 ;
    ARect[i].Tag    := i+1 ;
    ARect[i].Fill.Color :=$FF000000;
    {$IFNDEF MSWINDOWS}
    ARect[i].Touch.GestureManager := GestureManager1 ;
    ARect[i].Touch.InteractiveGestures :=[TInteractiveGesture.Zoom,TInteractiveGesture.Pan,TInteractiveGesture.Rotate,
                                          TInteractiveGesture.TwoFingerTap,TInteractiveGesture.PressAndTap];
    ARect[i].OnGesture   := FormGesture ;
    {$ENDIF}
    ARect[i].OnMouseDown := RectOnMouseDown ;
    ARect[i].OnMouseUp   := RectOnMouseUp ;
    ARect[i].OnMouseMove := RectOnMouseMove ;

AImage[i] := FMX.Objects.TImage.Create(nil);
    AImage[i].Parent := ARect[i] ;
    AImage[i].Tag    := i+1 ;
    AImage[i].Align  :=TAlignLayout.Client ;
    AImage[i].WrapMode :=TImageWrapMode.Fit;
    //AImage[i].Align:=TAlignLayout.Contents;
    //AImage[i].Width  := self.ClientWidth ;
    //AImage[i].Height :=self.Height;

AStream:= TMemoryStream.Create ;
    {$IFDEF MSWINDOWS}
    if FileExists(FImgListPath[i]) then
    begin
      try
        AStream.LoadFromFile(FImgListPath[i]);
        AImage[i].Bitmap.LoadFromStream(AStream);
      finally
        AStream.DisposeOf ;
      end;
    end
    else
        AImage[i].Bitmap.Assign(Image2.Bitmap);
    {$ELSE}
    if TFile.Exists(FImgListPath[i]) then
    begin
      try
        AStream.LoadFromFile(FImgListPath[i]);
        AImage[i].Bitmap.LoadFromStream(AStream);
      Finally
        AStream.DisposeOf ;
      end;
    end
    else
      AImage[i].Bitmap.Assign(Image2.Bitmap);
    {$ENDIF}

//AImage[i].WrapMode :=TImageWrapMode.Stretch ;
    AImage[i].HitTest  := true ;
    AImage[i].OnMouseDown := RectOnMouseDown ;
    AImage[i].OnMouseUp   := RectOnMouseUp ;
    AImage[i].OnMouseMove := RectOnMouseMove ;

//
    FOriginalWidth[i]  := AImage[i].Width ;
    FOriginalHeight[i] := AImage[i].Height ;
    FOriginalX[i]      := AImage[i].Position.X ;
    FOriginalY[i]      := AImage[i].Position.Y ;
    ARectIsCreate      := true ;
  end;

end;

procedure TFrmShowPictureZoomIn.InitImageStrPath;
var
  i : integer ;
  ARect   : Array of TRectangle ;
  ALabel  : TLabel ;
  ARectBottom : TRectangle;
  ARectTop    : TRectangle;
  ALblOk      : TLabel ;
begin
  setLength(ARect,7);
  setLength(AImage,FBitmapList.Count);
  setLength(FOriginalWidth,FBitmapList.Count);
  setLength(FOriginalHeight,FBitmapList.Count);
  setLength(FOriginalX,FBitmapList.Count);
  setLength(FOriginalY,FBitmapList.Count);
  for i := 0 to  2 do
  begin
    ARect[i] := TRectangle.Create(nil);
    ARect[i].Width := 50;
    ARect[i].height := self.ClientHeight ;
    ARect[i].Parent := LayoutContainer ;
    //ARect[i].Align  := TAlignLayout.Left ;
    if i>0 then
    begin
        ARect[i].Position.X :=ARect[i-1].Width *I ;
    end;
    ARect[i].Tag    := i+1 ;
    ARect[i].Fill.Color :=$FF33aadd;
    ALabel  := TLabel.Create(nil);
    ALabel.Parent := ARect[i] ;
    ALabel.text := 'aa'+inttostr(i);
    ALabel.Align := TAlignLayout.Left ;

end;

end;

procedure TFrmShowPictureZoomIn.LblOkClick(Sender: TObject);
begin
  //
end;

procedure TFrmShowPictureZoomIn.lblSelectOKClick(Sender: TObject);
begin
  ARectOnClick(Sender);
end;

procedure TFrmShowPictureZoomIn.LoadImgGuIDInfo;
var
  getdata1: TGetData;
  str,devicetype,ANameList: string;
  Atag: string;
  cds1: TClientDataSet;
  AList :TStringList;
  i,j:integer;
begin
  if not IsWebConnected then
  begin
    ShowTips(NoAvailableNetwork);
    Exit;
  end;
  //  StartLoading(Self);
    ASYNCStart(
      procedure
      begin
        try
         // showmessage('P_DEC_getIMGDetail'+','+BMSCarrierObject_ID);
         getdata1 := TGetData.Create(['P_DEC_getIMGDetail',
                                      BMSCarrierObject_ID]);

str := getdata1.GetResult;
          cds1 := getdata1.GetClientDataSet;
        finally
          getdata1.DisposeOf;
        end;

SYNCStart(
        procedure
          begin
             try
                i:=0;
                cds1.First;
                while not cds1.Eof do
                begin
                    ArrayOfGuID[i,0]:= cds1.FieldByName('ID_SL').AsString;
                    ArrayOfGuID[i,1]:=cds1.FieldByName('ID').AsString;
                    inc(i);
                    cds1.Next;
                end;
                finally
                  // LoadZoomImg(FCurrentIndex);
                   cds1.disposeof;
             end;
          end);
      end);
end;

procedure TFrmShowPictureZoomIn.LoadZoomImg(AIndex: integer);
var
  i,j:integer;
  ABitmap:Tbitmap;
  errmsg:string;
begin
  //if firstHit<>0 then
  ScrollMainView(AIndex);
  ASYNCStart(
  procedure
  var
  j:integer;
      begin
          i:=AIndex;
          ABitmap:= Tbitmap.Create;
          for j := 0 to AGuIDlist.Count-1 do
          begin
            if ArrayOfGuID[j,0]=AGuIDlist[i] then
            begin

TBitmapManager.DownLoadSingleBitMap(ArrayOfGuID[j,1],ABitmap,errmsg);
            end;
          end;
          SYNCStart(
          procedure
          begin
             AImage[i].Bitmap.Assign(ABitmap);
            // firstHit:=1;
          end);

end);
end;

procedure TFrmShowPictureZoomIn.RectOnMouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
  tapDownPos := TPointF.Create(X, Y);
  tapIsDown := true;
end;

procedure TFrmShowPictureZoomIn.RectOnMouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Single);
begin
  if tapIsDown  then
  begin
     FX := LayoutContainer.Position.X ;
     if (PageIndex>=0) and (PageIndex<=PageCount) then
     begin

if X - tapDownPos.X  < 0 then
       begin
          TAnimator.AnimateFloat(LayoutContainer, 'Position.X', LayoutContainer.Position.X + (X - tapDownPos.x), 0.5, TAnimationType.InOut, TInterpolationType.Linear );
       end
       else
       begin
          TAnimator.AnimateFloat(LayoutContainer, 'Position.X', LayoutContainer.Position.X + (X - tapDownPos.x), 0.5, TAnimationType.InOut, TInterpolationType.Linear );
       end;
     end;
  end;
end;

procedure TFrmShowPictureZoomIn.RectOnMouseUP(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Single);
var
  AMidX,AMidX1 :single ;
  ATag : integer ;
begin
   if FZoomWidth< FOriginalWidth[PageIndex] then
     begin
        AImage[PageIndex].Position.X := FOriginalX[PageIndex];
        AImage[PageIndex].Position.Y := FOriginalY[PageIndex] ;
        AImage[PageIndex].Width      := FOriginalWidth[PageIndex] ;
        AImage[PageIndex].Height     := FOriginalHeight[PageIndex] ;
     end;
  if tapIsDown then
  begin
     if Sender is TImage then
      ATag := TImage(Sender).Tag ;
     if Sender is TRectangle then
      ATag := TRectangle(Sender).Tag;

tapIsDown := false;
    if (pageIndex =0)  then
    begin
      if (X - tapDownPos.X + FX >0) then
         TAnimator.AnimateFloat(LayoutContainer, 'Position.X', 0, 0.5, TAnimationType.InOut, TInterpolationType.Circular )
      else
        if (X - tapDownPos.X + FX < -10) and (X - tapDownPos.X + FX > -80) then
           TAnimator.AnimateFloat(LayoutContainer, 'Position.X', 0, 0.5, TAnimationType.InOut, TInterpolationType.Linear )
        else
        begin
           Inc(pageIndex);

//   ScrollMainView(pageIndex);
        //   sleep(500);
           LoadZoomImg(pageIndex);
        end;
    end
    else
    begin

if (pageIndex = PageCount)   then
      begin

if X - tapDownPos.X + FX < 0 then
         begin   ///1111111111111
           if (X - tapDownPos.X + FX) + (self.ClientWidth * (pageindex)) <0 then
              TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (self.ClientWidth*(PageCount))*-1, 0.5, TAnimationType.InOut, TInterpolationType.Linear )
           else
           begin
             if ((X - tapDownPos.X + FX) + (self.ClientWidth * (pageindex ))>0) and
                ((X - tapDownPos.X + FX) + (self.ClientWidth * (pageindex ))<100) then
             begin
               TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (self.ClientWidth*(PageCount))*-1, 0.5, TAnimationType.InOut, TInterpolationType.Linear );
             end
             else
             begin
               Dec(pageIndex);
             //  ScrollMainView(pageIndex);
            //   sleep(500);
               LoadZoomImg(pageIndex);
             end;

end;
         end;
      end
      else
      begin
        // swipe left
        AMidX  := X - tapDownPos.X + FX ;
        AMidX1 := -(Self.ClientWidth*(pageIndex));
        if  AMidX - AMidX1 < 0  then
        begin
           if ((AMidX - AMidx1) < 0) and
              ((AMidX - AMidx1) > -120)  then
           begin
             TAnimator.AnimateFloat(LayoutContainer, 'Position.X', -(Self.ClientWidth*(pageIndex)), 0.5, TAnimationType.InOut, TInterpolationType.Linear );
           end
           else
           begin

Inc(pageIndex);
            // ScrollMainView(pageIndex);
            // sleep(500);
             LoadZoomImg(pageIndex);
           end;
        end
        // swipe right
        else
        begin
          if ((AMidX - AMidx1) > 0) and
              ((AMidX - AMidx1) < 80)  then
          begin
            ScrollMainView(pageIndex);
          end
          else
          begin
            dec(pageIndex);
          //  ScrollMainView(pageIndex);
           // sleep(500);
            LoadZoomImg(pageIndex);
          end;
        end;

end;
    end;
  end;

end;

procedure TFrmShowPictureZoomIn.RectTopClick(Sender: TObject);
begin
  TDRForm.Create(self).Release ;
end;

procedure TFrmShowPictureZoomIn.ScrollMainView(page: Integer);
begin
  //showmessage(pageIndex.ToString);
  pageIndex := page;
  Dec(page);
  TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (ClientWidth * (page+1)) * -1, 0.5, TAnimationType.Out, TInterpolationType.Exponential);

end;

class procedure TFrmShowPictureZoomIn.ShowForm(AListPath: TList<string>;
  AIndex: Integer);
begin
  with TDRForm.Create(TFrmShowPictureZoomIn).TCCF as TFrmShowPictureZoomIn do
  begin
    FImgListPath  := AListPath ;
    FCurrentIndex := AIndex ;
    InitFormInfo ;
    Show ;
    InitImageListPath ;
    InitCurrentImage ;
  end;
end;

class procedure TFrmShowPictureZoomIn.ShowForm(AList: TList<TBitmap>;BGuIDlist:Tstringlist;
  AIndex: integer;AMSCarrierObject_ID:string; AArrayOfGuID:TArrays);
    var
    i,j:integer;
    ABitmap:Tbitmap;
    errmsg:string;
begin
  with TDRForm.Create(TFrmShowPictureZoomIn).TCCF as TFrmShowPictureZoomIn do
  begin
    firstHit:=0;
    FBitmapList   := AList ;
    FCurrentIndex := AIndex ;
    BMSCarrierObject_ID:=AMSCarrierObject_ID;
    InitFormInfo;
    Show ;
    AGuIDlist:=Tstringlist.Create;
    AGuIDlist:=BGuIDlist;
    ArrayOfGuID:=AArrayOfGuID;
    //LoadImgGuIDInfo;
    InitImageList ;
    //InitCurrentImage ;
    LoadZoomImg(FCurrentIndex);
//    ABitmap:= Tbitmap.Create;
//    for j := 0 to AGuIDlist.Count-1 do
//    begin
//      if ArrayOfGuID[j,0]=AGuIDlist[FCurrentIndex] then
//      begin
//         //showmessage(ArrayOfGuID[j,0]+','+ArrayOfGuID[j,1]);
//         TBitmapManager.DownLoadSingleBitMap(ArrayOfGuID[j,1],ABitmap,errmsg);
//        // image3.Bitmap.Assign(ABitmap);
//         AImage[FCurrentIndex].Bitmap.Assign(ABitmap);
//         firstHit:=1;
//      end;
//    end;
  end;
end;

end.

delphi 预览图片2 (MouseUP)的更多相关文章

  1. hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images

    hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images, 本例子主要是使用HTML5 的File API,建立一個可存取到该file的url, 一个空的img标签,ID为img0,把 ...

  2. [js/jquery]移动端手势拖动,放大,缩小预览图片

    摘要 有这样的需求需要在手机端预览图片的时候,实现图片的手势拖动,放大缩小功能.最终通过touch.js这个插件实现了效果. touch.js Touch.js是移动设备上的手势识别与事件库, 由百度 ...

  3. ftp如何预览图片 解决方案

    下载使用 server-U ,开启 HTTP 服务,输入 http://ip:端口 后,登录ftp账号密码,可选使用 基于java的应用 web client 或 FTP Voyager JV,来预览 ...

  4. 本地预览图片html和js例子

    本地预览图片html和js例子,直接上代码吧. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...

  5. js矩阵菜单或3D立体预览图片效果

    js矩阵菜单或3D立体预览图片效果 下载地址: http://files.cnblogs.com/elves/js%E7%9F%A9%E9%98%B5%E8%8F%9C%E5%8D%95%E6%88% ...

  6. [.ashx檔?泛型处理例程?]基础入门#2....FileUpload上传前,预览图片(两种作法--ashx与JavaScript)

    原文出處  http://www.dotblogs.com.tw/mis2000lab/archive/2013/08/20/ashx_beginner_02_fileupload_picture_p ...

  7. input file 模拟预览图片。

    首先申明,接下来内容只是单纯的预览图片,最多选择九张,并没有和后台交互,交互的话需要自己另外写js. 本来想写一个调用摄像头的demo,意外的发现input file 在手机端打开的话,ios可以调用 ...

  8. Html5选择图片并及时预览图片

    以往想要实现图片预览基本都是先传至服务器后等返回链接地址才能进行预览,使用Html5选择图片并及时预览图片的代码如下,使用起来更爽了. <!DOCTYPE html> <html l ...

  9. 巧用weui.gallery(),点击图片后预览图片

    要在页面需要加载的JS文件: <script src="../js/libs/weui.min.js"></script> 可以去weui的文档中下载,这是 ...

随机推荐

  1. win7 安装 vagrant + centos + virtualbox

    Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用,“代码在我机子上运行没有问题”这种说辞将成为历史. 我的是在win7系 ...

  2. css Loading 教程

    http://www.cnblogs.com/lhb25/p/loading-spinners-animated-with-css3.html

  3. Android网络开发之Volley--Volley自定义Request

    1.自定义一个解析Json的Request,这里使用JackSon框架来解析Json.你也可以自定义一个解析XML的Request,或者使用FastSon来解析Json. 2.我们首先来看一下Stri ...

  4. lang

    我的docker容器里边,运行我的java进程时环境变量LANG为空导致乱码,重启java进程不为空显示正常:没有地方显式的设置过LANG,没找到/etc/(environment,profile,l ...

  5. Android Camera 调用流程总结

    1.总体介绍  Android Camera框架从整体上看是一个client/service架构.有两个进程,一个是client进程,可以看成AP端,主要包括Java代码和一些native层的c/c+ ...

  6. c语言 inline函数

    大学在教科书上学习过inline函数,定义为inline函数之后,会省去函数调用的开销,直接嵌套汇编代码,取代函数调用,提高效率. google的google c++ style guide 1.in ...

  7. (简单) POJ 2387 Til the Cows Come Home,Dijkstra。

    Description Bessie is out in the field and wants to get back to the barn to get as much sleep as pos ...

  8. 《javascript语言精粹》——第3章对象

    第三章:对象: 属性名字:可以是包括空字符串在内的任意字符串: 属性值:是除undefined值之外的任何值; [1].对象字面量: var obj={}; //空对象 var obj = new O ...

  9. Memcached源码分析之thread.c

    /* * 文件开头先啰嗦几句: * * thread.c文件代表的是线程模块.但是你会看到这个模块里面有很多其它方法, 例如关于item的各种操作函数,item_alloc,item_remove,i ...

  10. js实现的文章输入检查与测速。

    在群里聊天,一个群友求助.说要实现 文章对比输入,出错了标红,正确的标绿. 同时还需要统计正确率. 我一开始以为很容易,结果搞了半天.最后折腾出来了. 这里的思路如下:利用js的数组.将文章和输入的内 ...