本文整理汇总了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;
}