zoukankan      html  css  js  c++  java
  • [原创]Delphi XE Android/IOS 实现图片放大缩小的两种方法

    {该文首发于博客园 滔Roy,无须授权即可转发,请自觉保留头部申明}

    Delphi XE Android/IOS 实现图片放大缩小的两种方法

    1、TImage

    var
      LObj: IControl;
      LImage: TImage;
      LImageCenter: TPointF;
    begin
      if EventInfo.GestureID = igiZoom then
      begin
        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
            { zoom the image }
            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;
          end;
          FLastDistance := EventInfo.Distance;
        end;
      end;

    2、TImageViewer

    procedure TForm1.ImageViewer1Gesture(Sender: TObject;
      const EventInfo: TGestureEventInfo; var Handled: Boolean);
    begin
      case EventInfo.GestureID of
        igiZoom:
        begin
          if (EventInfo.Distance - fDistance)/2 > 0 then ImageViewer1.BitmapScale:=ImageViewer1.BitmapScale + 0.01  else
          if (EventInfo.Distance - fDistance)/2 < 0 then ImageViewer1.BitmapScale:=ImageViewer1.BitmapScale - 0.01;
          fDistance:=EventInfo.Distance;
          Handled:=True;
        end;
      end;
    end;
    

      

    创建时间:2020.06.26  更新时间:

  • 相关阅读:
    update语句
    java List和数组相互转换方法
    mysql查最大字符串
    Mybatis各种模糊查询
    mysql 递归查询父节点 和子节点
    String类型根据逗号分隔转为list
    This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de 错误解决办法
    java中String数组和List的互相转化
    实现List集合中数据逆序排列
    String字符串去掉双引号
  • 原文地址:https://www.cnblogs.com/guorongtao/p/13194167.html
Copyright © 2011-2022 走看看