/// <summary> /// Initializes a new instance of the <see cref="ThumbnailWriter"/> class. /// </summary> /// <param name="creator">The <see cref="ThumbnailCreator"/> /// (only used to get a jpeg compression encoder).</param> /// <param name="tgrid">The <see cref="ThumbnailGrid"/>.</param> /// <param name="directory">The directory to write the thumbnail page.</param> /// <param name="displayFilename">The display name of the <see cref="AVFileSet"/> /// from which the thumbnails are generated.</param> /// <param name="outTemplate">The template used to generate page filename.</param> /// <param name="nFiles">The number of files in set (>0 for multi-part videos).</param> /// <param name="stats">The stats of the <see cref="AVFileSet"/> to display /// in header.</param> /// <param name="duration">The duration of the <see cref="AVFileSet"/>.</param> public ThumbnailWriter(ThumbnailCreator creator, ThumbnailGrid tgrid, string directory, string displayFilename, string outTemplate, int nFiles, string stats, TimeSpan duration) { this._creator = creator; this._tgrid = tgrid; this._directory = directory; this._displayFilename = displayFilename; this._outTemplate = outTemplate; this._nFiles = nFiles; this._stats = stats; this._duration = duration; _thumbnailPage = null; }
/// <summary> /// Initializes a new instance of the <see cref="ThumbnailMultiWriter"/> class. /// </summary> /// <param name="creator">The <see cref="ThumbnailCreator"/> /// (only used to get a jpeg compression encoder).</param> /// <param name="tgrid">The <see cref="ThumbnailGrid"/>.</param> /// <param name="directory">The directory to write thumbnail pages.</param> /// <param name="displayFilename">The display name of the <see cref="AVFileSet"/> /// from which the thumbnails are generated.</param> /// <param name="outTemplate">The template used to generate page filenames.</param> /// <param name="nFiles">The number of files in set (>0 for multi-part videos).</param> /// <param name="interval">The interval between thumbnails.</param> /// <param name="stats">The stats of the <see cref="AVFileSet"/> to display /// in header.</param> /// <param name="duration">The duration of the <see cref="AVFileSet"/>.</param> /// <param name="nPages">The total number of thumbnail pages.</param> public ThumbnailMultiWriter(ThumbnailCreator creator, ThumbnailGrid tgrid, string directory, string displayFilename, string outTemplate, int nFiles, TimeSpan interval, string stats, TimeSpan duration, int nPages) { this._creator = creator; this._tgrid = tgrid; this._directory = directory; this._displayFilename = displayFilename; this._outTemplate = outTemplate; this._nFiles = nFiles; this._interval = interval; this._stats = stats; this._duration = duration; this._nPages = nPages; this._pageNum = 1; _thumbnailPage = null; }
/// <summary> /// Initializes a new instance of the <see cref="ThumbnailPage"/> class. /// </summary> /// <param name="creator">The <see cref="ThumbnailCreator"/> /// (only used to get a jpeg compression encoder).</param> /// <param name="tgrid">The <see cref="ThumbnailGrid"/> that specifies /// the page layout.</param> /// <param name="displayFilename">The display name of the <see cref="AVFileSet"/> /// from which the thumbnails are generated.</param> /// <param name="filename">The fullpath of thumbnail page to create.</param> /// <param name="nFiles">The number of files in set (>0 for multi-part videos).</param> /// <param name="time">The time of first thumbnail on page.</param> /// <param name="pageNum">The page number (0 for overview page).</param> /// <param name="duration">The duration of the <see cref="AVFileSet"/>.</param> /// <param name="nPages">The total number of thumbnail pages.</param> /// <param name="stats">The stats of the <see cref="AVFileSet"/> to display /// in header.</param> public ThumbnailPage(ThumbnailCreator creator, ThumbnailGrid tgrid, string displayFilename, string filename, int nFiles, TimeSpan time, int pageNum, TimeSpan duration, int nPages, string stats) { this._creator = creator; this._tgrid = tgrid; this._filename = filename; _pageBitmap = new System.Drawing.Bitmap (tgrid.Layout.Width, tgrid.Layout.Height); _graphics = System.Drawing.Graphics.FromImage (_pageBitmap); _graphics.PageUnit = System.Drawing.GraphicsUnit.Pixel; _graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; //_graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; _graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; //_graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; _graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; // can't use TextRenderingHint.ClearTypeGridFit with CompositingMode.SourceCopy //_graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; //_graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; _graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; // Affects image resizing _graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; // Affects anti-aliasing of filled edges //_graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; _graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; _font = new System.Drawing.Font ("Arial", (float) (7 * creator.TNSettings.ScaleFactor), System.Drawing.FontStyle.Bold); _brushWhite = new System.Drawing.SolidBrush (System.Drawing.Color.White); _brushBlack = new System.Drawing.SolidBrush (System.Drawing.Color.Black); _borderPen = new System.Drawing.Pen (System.Drawing.Color.Wheat, tgrid.Layout.Border <= 1 ? 0 : tgrid.Layout.Border); _borderHilightPen = new System.Drawing.Pen (System.Drawing.Color.Red, tgrid.Layout.Border <= 1 ? 0 : tgrid.Layout.Border); //_borderPen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset; //_borderPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Miter; _graphics.FillRectangle (_brushBlack, 0, 0, tgrid.Layout.Width, tgrid.Layout.Height); _thumbFormat = new System.Drawing.StringFormat (); switch (creator.TNSettings.LabelPosition) { case ThumbnailSettings.LabelPositions.None: case ThumbnailSettings.LabelPositions.LowerRight: { _thumbFormat.LineAlignment = System.Drawing.StringAlignment.Far; _thumbFormat.Alignment = System.Drawing.StringAlignment.Far; break; } case ThumbnailSettings.LabelPositions.LowerLeft: { _thumbFormat.LineAlignment = System.Drawing.StringAlignment.Far; _thumbFormat.Alignment = System.Drawing.StringAlignment.Near; break; } case ThumbnailSettings.LabelPositions.UpperRight: { _thumbFormat.LineAlignment = System.Drawing.StringAlignment.Near; _thumbFormat.Alignment = System.Drawing.StringAlignment.Far; break; } case ThumbnailSettings.LabelPositions.UpperLeft: { _thumbFormat.LineAlignment = System.Drawing.StringAlignment.Near; _thumbFormat.Alignment = System.Drawing.StringAlignment.Near; break; } } _headerFormat = new System.Drawing.StringFormat (); _headerFormat.LineAlignment = System.Drawing.StringAlignment.Center; _headerFormat.Alignment = System.Drawing.StringAlignment.Near; float inset = 2*tgrid.Layout.Margin; System.Drawing.RectangleF headerRectF = new System.Drawing.RectangleF (inset, 0, this._tgrid.Layout.Width - 2*inset, this._tgrid.Layout.HeaderHeight); //_graphics.DrawRectangle (_borderPen, // headerRectF.X, // headerRectF.Y, // headerRectF.Width, // headerRectF.Height); string leftSide; string timeformat = @"h\:mm\:ss"; if (time.Milliseconds > 0 && creator.TNSettings.AlwaysShowMilliseconds) timeformat = @"h\:mm\:ss\.ffff"; if (pageNum > 0) leftSide = String.Format ("{0} / {1} ({2} of {3})", time.ToString (timeformat), duration.ToString (@"h\:mm\:ss"), pageNum, nPages); else leftSide = String.Format ("{0}", duration.ToString (@"h\:mm\:ss")); if (nFiles > 0) leftSide += String.Format (" {0} files", nFiles); using (System.Drawing.Font headerFont = new System.Drawing.Font ( ThumbnailPageLayout.FONT_NAME, (float) (ThumbnailPageLayout.FONT_SIZE * creator.TNSettings.ScaleFactor), System.Drawing.FontStyle.Bold)) { _graphics.DrawString (leftSide, headerFont, _brushWhite, headerRectF, _headerFormat); _headerFormat.Alignment = System.Drawing.StringAlignment.Far; _graphics.DrawString (stats, headerFont, _brushWhite, headerRectF, _headerFormat); float left = headerRectF.Left + _graphics.MeasureString(leftSide, headerFont).Width; float right = headerRectF.Right - _graphics.MeasureString (stats, headerFont).Width; headerRectF = new System.Drawing.RectangleF ( left, headerRectF.Top, right - left, headerRectF.Height); _headerFormat.Alignment = System.Drawing.StringAlignment.Center; _graphics.DrawString (displayFilename, headerFont, _brushWhite, headerRectF, _headerFormat); } _pageNum = pageNum; _currentCol = 0; _currentRow = 0; }
/// <summary> /// Create ThumbnailGrid the using desired # of rows. /// </summary> /// <param name="layout">The <see cref="ThumbnailPageLayout"/>.</param> /// <param name="nRows">The desired # of rows.</param> /// <param name="aspectRatio">The thumbnail aspect ratio.</param> /// <returns>new <see cref="ThumbnailGrid"/></returns> private static ThumbnailGrid CreateUsingNRows(ThumbnailPageLayout layout, int nRows, double aspectRatio) { int nColumns; int thumbWidth; int thumbHeight; thumbHeight = layout.CalcThumbHeightFromNRows (nRows); thumbWidth = (int) (thumbHeight * aspectRatio + 0.5); nColumns = layout.CalcColumnsFromThumbWidth (thumbWidth); ThumbnailGrid thumbnailGrid = new ThumbnailGrid (layout, nColumns, nRows, thumbWidth, thumbHeight); return thumbnailGrid; }
/// <summary> /// Create ThumbnailGrid the using desired # of columns. /// </summary> /// <param name="layout">The <see cref="ThumbnailPageLayout"/>.</param> /// <param name="nColumns">The desired # of columns.</param> /// <param name="aspectRatio">The thumbnail aspect ratio.</param> /// <returns> /// new <see cref="ThumbnailGrid"/> /// </returns> private static ThumbnailGrid CreateUsingNColumns(ThumbnailPageLayout layout, int nColumns, double aspectRatio) { int nRows; int thumbWidth; int thumbHeight; thumbWidth = layout.CalcThumbWidthFromNCols (nColumns); thumbHeight = (int) (thumbWidth / aspectRatio + 0.5); nRows = layout.CalcRowsFromThumbHeight (thumbHeight); ThumbnailGrid thumbnailGrid = new ThumbnailGrid (layout, nColumns, nRows, thumbWidth, thumbHeight); return thumbnailGrid; }
/// <summary> /// Create ThumbnailGrid the using desired thumbnail width. /// </summary> /// <param name="layout">The <see cref="ThumbnailPageLayout"/>.</param> /// <param name="thumbWidth">The desired thumbnail width.</param> /// <param name="aspectRatio">The thumbnail aspect ratio.</param> /// <returns>new <see cref="ThumbnailGrid"/></returns> public static ThumbnailGrid CreateUsingThumbWidth(ThumbnailPageLayout layout, int thumbWidth, double aspectRatio) { int nRows; int nColumns; int thumbHeight; nColumns = layout.CalcColumnsFromThumbWidth(thumbWidth); thumbHeight = (int) (thumbWidth / aspectRatio + 0.5); nRows = layout.CalcRowsFromThumbHeight (thumbHeight); ThumbnailGrid thumbnailGrid = new ThumbnailGrid (layout, nColumns, nRows, thumbWidth, thumbHeight); return thumbnailGrid; }
/// <summary> /// Create ThumbnailGrid the using desired columns & rows. /// </summary> /// <param name="layout">The <see cref="ThumbnailPageLayout"/>.</param> /// <param name="nColumns">The # of columns.</param> /// <param name="nRows">The # of rows.</param> /// <param name="aspectRatio">The thumbnail aspect ratio.</param> /// <param name="fitWidth">if set to <c>true</c>use page layout width, /// otherwise use page layout height.</param> /// <returns>new <see cref="ThumbnailGrid"/></returns> public static ThumbnailGrid CreateUsingRaw(ThumbnailPageLayout layout, int nColumns, int nRows, double aspectRatio, bool fitWidth) { int thumbWidth; int thumbHeight; if (fitWidth) { thumbWidth = layout.CalcThumbWidthFromNCols (nColumns); thumbHeight = (int) (thumbWidth / aspectRatio + 0.5); layout.AdjustHeight (nRows, thumbHeight); } else { thumbHeight = layout.CalcThumbHeightFromNRows (nRows); thumbWidth = (int) (thumbHeight * aspectRatio + 0.5); layout.AdjustWidth (nColumns, thumbWidth); } ThumbnailGrid thumbnailGrid = new ThumbnailGrid (layout, nColumns, nRows, thumbWidth, thumbHeight); layout.AdjustSize (thumbnailGrid); return thumbnailGrid; }