internal void Draw(Rectangle rect, Color color, MyVideoRectangleFitMode fitMode) { int w = 0, h = 0; byte [] data = m_wrapper.GetTextureData(ref w, ref h); process_frame(data, w, h); Rectangle dst = rect; Rectangle src = new Rectangle(0, 0, w, h); var videoSize = new Vector2(w, h); float videoAspect = videoSize.X / videoSize.Y; float rectAspect = (float)rect.Width / (float)rect.Height; // Automatic decision based on ratios. if (fitMode == MyVideoRectangleFitMode.AutoFit) fitMode = (videoAspect > rectAspect) ? MyVideoRectangleFitMode.FitHeight : MyVideoRectangleFitMode.FitWidth; float scaleRatio = 0.0f; switch (fitMode) { case MyVideoRectangleFitMode.None: break; case MyVideoRectangleFitMode.FitWidth: scaleRatio = (float)dst.Width / videoSize.X; dst.Height = (int)(scaleRatio * videoSize.Y); if (dst.Height > rect.Height) { var diff = dst.Height - rect.Height; dst.Height = rect.Height; diff = (int)(diff / scaleRatio); src.Y += (int)(diff * 0.5f); src.Height -= diff; } break; case MyVideoRectangleFitMode.FitHeight: scaleRatio = (float)dst.Height / videoSize.Y; dst.Width = (int)(scaleRatio * videoSize.X); if (dst.Width > rect.Width) { var diff = dst.Width - rect.Width; dst.Width = rect.Width; diff = (int)(diff / scaleRatio); src.X += (int)(diff * 0.5f); src.Width -= diff; } break; } dst.X = rect.Left + (rect.Width - dst.Width) / 2; dst.Y = rect.Top + (rect.Height - dst.Height) / 2; VRageMath.RectangleF destination = new VRageMath.RectangleF(dst.X, dst.Y, dst.Width, -dst.Height); VRageMath.Rectangle? source = src; Vector2 origin = new Vector2(src.Width / 2 * 0, src.Height); MySpritesRenderer.AddSingleSprite(m_texture, videoSize, color, origin, Vector2.UnitX, source, destination); }
internal void Draw(Rectangle rect, Color color, MyVideoRectangleFitMode fitMode) { Rectangle dst = rect; Rectangle src = new Rectangle(0, 0, VideoWidth, VideoHeight); var videoSize = new Vector2(VideoWidth, VideoHeight); float videoAspect = videoSize.X / videoSize.Y; float rectAspect = (float)rect.Width / (float)rect.Height; // Automatic decision based on ratios. if (fitMode == MyVideoRectangleFitMode.AutoFit) { fitMode = (videoAspect > rectAspect) ? MyVideoRectangleFitMode.FitHeight : MyVideoRectangleFitMode.FitWidth; } float scaleRatio = 0.0f; switch (fitMode) { case MyVideoRectangleFitMode.None: break; case MyVideoRectangleFitMode.FitWidth: scaleRatio = (float)dst.Width / videoSize.X; dst.Height = (int)(scaleRatio * videoSize.Y); if (dst.Height > rect.Height) { var diff = dst.Height - rect.Height; dst.Height = rect.Height; diff = (int)(diff / scaleRatio); src.Y += (int)(diff * 0.5f); src.Height -= diff; } break; case MyVideoRectangleFitMode.FitHeight: scaleRatio = (float)dst.Height / videoSize.Y; dst.Width = (int)(scaleRatio * videoSize.X); if (dst.Width > rect.Width) { var diff = dst.Width - rect.Width; dst.Width = rect.Width; diff = (int)(diff / scaleRatio); src.X += (int)(diff * 0.5f); src.Width -= diff; } break; } dst.X = rect.Left + (rect.Width - dst.Width) / 2; dst.Y = rect.Top + (rect.Height - dst.Height) / 2; VRageMath.RectangleF destination = new VRageMath.RectangleF(dst.X, dst.Y, dst.Width, -dst.Height); VRageMath.Rectangle? source = src; Vector2 origin = new Vector2(src.Width / 2 * 0, src.Height); MySpritesRenderer.AddSingleSprite(m_texture.ShaderView, videoSize, color, origin, Vector2.UnitX, source, destination); }
static void DrawVideo(uint id, Rectangle rect, Color color, MyVideoRectangleFitMode fitMode) { MyVideoPlayerDx9 video; if (m_videos.TryGetValue(id, out video)) { Rectangle dst = rect; Rectangle src = new Rectangle(0, 0, video.VideoWidth, video.VideoHeight); var videoSize = new Vector2(video.VideoWidth, video.VideoHeight); float videoAspect = videoSize.X / videoSize.Y; float rectAspect = (float)rect.Width / (float)rect.Height; // Automatic decision based on ratios. if (fitMode == MyVideoRectangleFitMode.AutoFit) fitMode = (videoAspect > rectAspect) ? MyVideoRectangleFitMode.FitHeight : MyVideoRectangleFitMode.FitWidth; float scaleRatio = 0.0f; switch (fitMode) { case MyVideoRectangleFitMode.None: break; case MyVideoRectangleFitMode.FitWidth: scaleRatio = (float)dst.Width / videoSize.X; dst.Height = (int)(scaleRatio * videoSize.Y); if (dst.Height > rect.Height) { var diff = dst.Height - rect.Height; dst.Height = rect.Height; diff = (int)(diff / scaleRatio); src.Y += (int)(diff * 0.5f); src.Height -= diff; } break; case MyVideoRectangleFitMode.FitHeight: scaleRatio = (float)dst.Height / videoSize.Y; dst.Width = (int)(scaleRatio * videoSize.X); if (dst.Width > rect.Width) { var diff = dst.Width - rect.Width; dst.Width = rect.Width; diff = (int)(diff / scaleRatio); src.X += (int)(diff * 0.5f); src.Width -= diff; } break; } dst.X = rect.Left + (rect.Width - dst.Width) / 2; dst.Y = rect.Top + (rect.Height - dst.Height) / 2; Texture texture = video.OutputFrame; // Draw upside down VRageMath.RectangleF destination = new VRageMath.RectangleF(dst.X, dst.Y, dst.Width, -dst.Height); VRageMath.Rectangle? source = src; Vector2 origin = new Vector2(src.Width / 2 * 0, src.Height); MyRender.DrawSprite(texture, null, ref destination, false, ref source, color, Vector2.UnitX, ref origin, VRageRender.Graphics.SpriteEffects.None, 0f); } }
static void DrawVideo(uint id, Rectangle rect, Color color, MyVideoRectangleFitMode fitMode) { MyVideoPlayerDx9 video; if (m_videos.TryGetValue(id, out video)) { Rectangle dst = rect; Rectangle src = new Rectangle(0, 0, video.VideoWidth, video.VideoHeight); var videoSize = new Vector2(video.VideoWidth, video.VideoHeight); float videoAspect = videoSize.X / videoSize.Y; float rectAspect = (float)rect.Width / (float)rect.Height; // Automatic decision based on ratios. if (fitMode == MyVideoRectangleFitMode.AutoFit) { fitMode = (videoAspect > rectAspect) ? MyVideoRectangleFitMode.FitHeight : MyVideoRectangleFitMode.FitWidth; } float scaleRatio = 0.0f; switch (fitMode) { case MyVideoRectangleFitMode.None: break; case MyVideoRectangleFitMode.FitWidth: scaleRatio = (float)dst.Width / videoSize.X; dst.Height = (int)(scaleRatio * videoSize.Y); if (dst.Height > rect.Height) { var diff = dst.Height - rect.Height; dst.Height = rect.Height; diff = (int)(diff / scaleRatio); src.Y += (int)(diff * 0.5f); src.Height -= diff; } break; case MyVideoRectangleFitMode.FitHeight: scaleRatio = (float)dst.Height / videoSize.Y; dst.Width = (int)(scaleRatio * videoSize.X); if (dst.Width > rect.Width) { var diff = dst.Width - rect.Width; dst.Width = rect.Width; diff = (int)(diff / scaleRatio); src.X += (int)(diff * 0.5f); src.Width -= diff; } break; } dst.X = rect.Left + (rect.Width - dst.Width) / 2; dst.Y = rect.Top + (rect.Height - dst.Height) / 2; Texture texture = video.OutputFrame; // Draw upside down VRageMath.RectangleF destination = new VRageMath.RectangleF(dst.X, dst.Y, dst.Width, -dst.Height); VRageMath.Rectangle? source = src; Vector2 origin = new Vector2(src.Width / 2 * 0, src.Height); MyRender.DrawSprite(texture, null, ref destination, false, ref source, color, Vector2.UnitX, ref origin, VRageRender.Graphics.SpriteEffects.None, 0f); } }
public static void DrawVideo(uint id, Rectangle rect, Color color, MyVideoRectangleFitMode fitMode = MyVideoRectangleFitMode.None) { var message = MessagePool.Get<MyRenderMessageDrawVideo>(MyRenderMessageEnum.DrawVideo); message.ID = id; message.Rectangle = rect; message.Color = color; message.FitMode = fitMode; EnqueueMessage(message); }
static void DrawVideo(uint id, Rectangle rect, Color color, MyVideoRectangleFitMode fitMode) { Debug.Assert(false); }
internal void Draw(Rectangle rect, Color color, MyVideoRectangleFitMode fitMode) { //Debug.Assert(false, "Video DRAW Not Supported yet on XB1!"); }