/// <summary> /// Computes a new size by keeping the width the same and resizing the height to fit the provided aspect ratio /// type. /// </summary> /// <param name="videoAspectRatioType">The aspect ratio type that bounds the height.</param> /// <param name="currentSize">The current size of the video.</param> /// <returns>A new size with the same width but a new height that conforms to the provided aspect /// ratio type.</returns> public static Size ResizeHeightToAspectRatio(VideoAspectRatioType videoAspectRatioType, Size currentSize) { if (videoAspectRatioType == VideoAspectRatioType.Unknown) { throw new ArgumentException("videoAspectRatioType cannot be VideoAspectRatioType.Unknown"); } return(ResizeHeightToAspectRatio( videoAspectRatioType == VideoAspectRatioType.Standard ? StandardAspectRatio : WidescreenAspectRatio, currentSize)); }
/// <summary> /// Computes a new size by keeping the width the same and resizing the height to fit the provided aspect ratio /// type. /// </summary> /// <param name="videoAspectRatioType">The aspect ratio type that bounds the height.</param> /// <param name="currentSize">The current size of the video.</param> /// <returns>A new size with the same width but a new height that conforms to the provided aspect /// ratio type.</returns> public static Size ResizeHeightToAspectRatio(VideoAspectRatioType videoAspectRatioType, Size currentSize) { if (videoAspectRatioType == VideoAspectRatioType.Unknown) { throw new ArgumentException("videoAspectRatioType cannot be VideoAspectRatioType.Unknown"); } return ResizeHeightToAspectRatio( videoAspectRatioType == VideoAspectRatioType.Standard ? StandardAspectRatio : WidescreenAspectRatio, currentSize); }
private void VideoAspectRatio_Execute(object sender, EventArgs e) { Command commandExecuted = (Command)sender; VideoAspectRatioType newAspectRatioType = (VideoAspectRatioType)commandExecuted.Tag; if (_VideoContent.AspectRatioType != newAspectRatioType) { _VideoContent.AspectRatioType = newAspectRatioType; OnContentEdited(); } UpdateAspectRatio(); }
public Video(string id, string url, string embed, string editorFormat, VideoProvider provider, int width, int height, VideoAspectRatioType aspectRatioType) { _id = id; _url = url; _embed = embed; _provider = provider; _width = width; _height = height; _editorFormat = editorFormat; AspectRatioType = aspectRatioType; if (AspectRatioType != VideoAspectRatioType.Unknown) { _height = VideoAspectRatioHelper.ResizeHeightToAspectRatio(AspectRatioType, new Size(width, height)).Height; } }
#pragma warning restore 414 /// <summary> /// Constructs a <see cref="VideoTrack" /> parsing from provided /// file data. /// Parsing will be done reading from _file at position references by /// parent element's data section. /// </summary> /// <param name="_file"><see cref="File" /> instance to read from.</param> /// <param name="element">Parent <see cref="EBMLreader" />.</param> public VideoTrack(File _file, EBMLreader element) : base(_file, element) { MatroskaID matroska_id; // Here we handle the unknown elements we know, and store the rest foreach (var elem in base.UnknownElements) { matroska_id = elem.ID; switch (matroska_id) { case MatroskaID.TrackVideo: { ulong i = 0; while (i < elem.DataSize) { var child = new EBMLreader(_file, elem.DataOffset + i); matroska_id = child.ID; switch (matroska_id) { case MatroskaID.VideoDisplayWidth: disp_width = child.ReadULong(); break; case MatroskaID.VideoDisplayHeight: disp_height = child.ReadULong(); break; case MatroskaID.VideoPixelWidth: width = child.ReadULong(); break; case MatroskaID.VideoPixelHeight: height = child.ReadULong(); break; case MatroskaID.VideoFrameRate: framerate = child.ReadDouble(); break; case MatroskaID.VideoFlagInterlaced: interlaced = child.ReadBool(); break; case MatroskaID.VideoAspectRatioType: ratio_type = (VideoAspectRatioType)child.ReadULong(); break; case MatroskaID.VideoColourSpace: fourcc = child.ReadBytes(); break; default: UnknownElements.Add(child); break; } i += child.Size; } break; } case MatroskaID.TrackDefaultDuration: var tmp = elem.ReadULong(); framerate = 1000000000.0 / tmp; break; default: UnknownElements.Add(elem); break; } } }
/// <summary> /// Constructs a <see cref="VideoTrack" /> parsing from provided /// file data. /// Parsing will be done reading from _file at position references by /// parent element's data section. /// </summary> /// <param name="_file"><see cref="File" /> instance to read from.</param> /// <param name="element">Parent <see cref="EBMLElement" />.</param> public VideoTrack (File _file, EBMLElement element) : base (_file, element) { MatroskaID matroska_id; // Here we handle the unknown elements we know, and store the rest foreach (EBMLElement elem in base.UnknownElements) { matroska_id = (MatroskaID) elem.ID; if (matroska_id == MatroskaID.MatroskaTrackVideo) { ulong i = 0; while (i < elem.DataSize) { EBMLElement child = new EBMLElement (_file, elem.DataOffset + i); matroska_id = (MatroskaID) child.ID; switch (matroska_id) { case MatroskaID.MatroskaVideoDisplayWidth: disp_width = child.ReadUInt (); break; case MatroskaID.MatroskaVideoDisplayHeight: disp_height = child.ReadUInt (); break; case MatroskaID.MatroskaVideoPixelWidth: width = child.ReadUInt (); break; case MatroskaID.MatroskaVideoPixelHeight: height = child.ReadUInt (); break; case MatroskaID.MatroskaVideoFrameRate: framerate = child.ReadDouble (); break; case MatroskaID.MatroskaVideoFlagInterlaced: interlaced = child.ReadBool (); break; case MatroskaID.MatroskaVideoAspectRatioType: ratio_type = (VideoAspectRatioType) child.ReadUInt (); break; case MatroskaID.MatroskaVideoColourSpace: fourcc = child.ReadBytes (); break; default: unknown_elems.Add (child); break; } i += child.Size; } } else if (matroska_id == MatroskaID.MatroskaTrackDefaultDuration) { uint tmp = elem.ReadUInt (); framerate = 1000000000.0 / (double) tmp; } else { unknown_elems.Add (elem); } } }
/// <summary> /// Constructs a <see cref="VideoTrack" /> parsing from provided /// file data. /// Parsing will be done reading from _file at position references by /// parent element's data section. /// </summary> /// <param name="_file"><see cref="File" /> instance to read from.</param> /// <param name="element">Parent <see cref="EBMLElement" />.</param> public VideoTrack(File _file, EBMLElement element) : base(_file, element) { MatroskaID matroska_id; // Here we handle the unknown elements we know, and store the rest foreach (EBMLElement elem in base.UnknownElements) { matroska_id = (MatroskaID)elem.ID; if (matroska_id == MatroskaID.MatroskaTrackVideo) { ulong i = 0; while (i < elem.DataSize) { EBMLElement child = new EBMLElement(_file, elem.DataOffset + i); matroska_id = (MatroskaID)child.ID; switch (matroska_id) { case MatroskaID.MatroskaVideoDisplayWidth: disp_width = child.ReadUInt(); break; case MatroskaID.MatroskaVideoDisplayHeight: disp_height = child.ReadUInt(); break; case MatroskaID.MatroskaVideoPixelWidth: width = child.ReadUInt(); break; case MatroskaID.MatroskaVideoPixelHeight: height = child.ReadUInt(); break; case MatroskaID.MatroskaVideoFrameRate: framerate = child.ReadDouble(); break; case MatroskaID.MatroskaVideoFlagInterlaced: interlaced = child.ReadBool(); break; case MatroskaID.MatroskaVideoAspectRatioType: ratio_type = (VideoAspectRatioType)child.ReadUInt(); break; case MatroskaID.MatroskaVideoColourSpace: fourcc = child.ReadBytes(); break; default: unknown_elems.Add(child); break; } i += child.Size; } } else if (matroska_id == MatroskaID.MatroskaTrackDefaultDuration) { uint tmp = elem.ReadUInt(); framerate = 1000000000.0 / (double)tmp; } else { unknown_elems.Add(elem); } } }