當前位置: 首頁>>代碼示例>>C#>>正文


C# Size2F.ToDrawingSizeF方法代碼示例

本文整理匯總了C#中SharpDX.Size2F.ToDrawingSizeF方法的典型用法代碼示例。如果您正苦於以下問題:C# Size2F.ToDrawingSizeF方法的具體用法?C# Size2F.ToDrawingSizeF怎麽用?C# Size2F.ToDrawingSizeF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SharpDX.Size2F的用法示例。


在下文中一共展示了Size2F.ToDrawingSizeF方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RefreshEffectParameters

    protected bool RefreshEffectParameters(IVideoPlayer player)
    {
      ISharpDXVideoPlayer sdvPlayer = player as ISharpDXVideoPlayer;
      if (sdvPlayer == null)
        return false;
      SizeF aspectRatio = sdvPlayer.VideoAspectRatio.ToSize2F();
      Size playerSize = sdvPlayer.VideoSize.ToSize2();
      Rectangle cropVideoRect = sdvPlayer.CropVideoRect;
      IGeometry geometry = ChooseVideoGeometry(player);
      string effectName = player.EffectOverride;
      int deviceWidth = GraphicsDevice.Width; // To avoid threading issues if the device size changes
      int deviceHeight = GraphicsDevice.Height;
      RectangleF vertsBounds = _vertsBounds;

      // Do we need a refresh?
      if (!_refresh &&
          _lastVideoSize == playerSize &&
          _lastAspectRatio == aspectRatio &&
          _lastCropVideoRect == cropVideoRect &&
          _lastGeometry == geometry &&
          _lastEffect == effectName &&
          _lastDeviceWidth == deviceWidth &&
          _lastDeviceHeight == deviceHeight &&
          _lastVertsBounds == vertsBounds)
        return true;

      SizeF targetSize = vertsBounds.Size;

      lock (sdvPlayer.SurfaceLock)
      {
        Surface surface = sdvPlayer.Surface;
        if (surface == null)
        {
          _refresh = true;
          return false;
        }
        SurfaceDescription desc = surface.Description;
        _videoTextureClip = new RectangleF(cropVideoRect.X / desc.Width, cropVideoRect.Y / desc.Height,
            cropVideoRect.Width / desc.Width, cropVideoRect.Height / desc.Height);
      }
      _scaledVideoSize = cropVideoRect.Size.ToSize2F();

      // Correct aspect ratio for anamorphic video
      if (!aspectRatio.IsEmpty() && geometry.RequiresCorrectAspectRatio)
      {
        float pixelRatio = aspectRatio.Width / aspectRatio.Height;
        _scaledVideoSize.Width = _scaledVideoSize.Height * pixelRatio;
      }
      // Adjust target size to match final Skin scaling
      targetSize = ImageContext.AdjustForSkinAR(targetSize);

      // Adjust video size to fit desired geometry
      _scaledVideoSize = geometry.Transform(_scaledVideoSize.ToDrawingSizeF(), targetSize.ToDrawingSizeF()).ToSize2F();

      // Cache inverse RelativeTransform
      Transform relativeTransform = RelativeTransform;
      _inverseRelativeTransformCache = (relativeTransform == null) ? Matrix.Identity : Matrix.Invert(relativeTransform.GetTransform());

      // Prepare our ImageContext
      _imageContext.FrameSize = targetSize;
      _imageContext.ShaderBase = EFFECT_BASE_VIDEO;
      _imageContext.ShaderTransform = geometry.Shader;
      _imageContext.ShaderEffect = player.EffectOverride;

      // Store state
      _lastFrameData = new Vector4(playerSize.Width, playerSize.Height, 0.0f, 0.0f);
      _lastVideoSize = playerSize;
      _lastAspectRatio = aspectRatio;
      _lastGeometry = geometry;
      _lastCropVideoRect = cropVideoRect;
      _lastEffect = effectName;
      _lastDeviceWidth = deviceWidth;
      _lastDeviceHeight = deviceHeight;

      _refresh = false;
      return true;
    }
開發者ID:BigGranu,項目名稱:MediaPortal-2,代碼行數:77,代碼來源:VideoBrush.cs


注:本文中的SharpDX.Size2F.ToDrawingSizeF方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。