Example #1
0
        /// <summary>
        /// Creates a JPEG file from a UIElement, named [radix]_[width]x[height].jpg.
        /// </summary>
        /// <param name="uie">The UIElement.</param>
        /// <param name="pixelWidth">The width of the bitmap.</param>
        /// <param name="pixelHeight">The height of the bitmap.</param>
        /// <param name="dpi">The DPI of the bitmap.</param>
        /// <param name="background">A background brush.</param>
        /// <param name="directory">The output directory (optional).</param>
        /// <param name="fileRadix">The radix label of the file.</param>
        public static void CreateJpegFile(UIElement uie, int pixelWidth, int pixelHeight, int dpi, string directory, string fileRadix)
        {
            DrawingHelper.BuildLayout(uie, new Size(pixelWidth, pixelHeight));
            var fileName = String.Format("{2}_{0}x{1}.jpg", pixelWidth, pixelHeight, fileRadix);
            var filePath = String.IsNullOrEmpty(directory) ? fileName : Path.Combine(directory, fileName);

            CreateImageFile(uie, pixelWidth, pixelHeight, dpi, dpi, null, filePath, new JpegBitmapEncoder());
        }