コード例 #1
0
        /// <summary>
        /// Scales the foreground image by X percent
        /// </summary>
        /// <param name="scale">Expects a value between [0.0,1.0]. Beyond 1.0 will scale the image larger.</param>
        private static Image <Rgba32> ScaleImage(Image <Rgba32> sourceImage, double scale)
        {
            var canvasWidth  = UpscaledCanvasWidth;
            var canvasHeight = UpscaledCanvasHeight;
            var resizeWidth  = (int)Math.Max(canvasWidth * scale, 1.0);
            var resizeHeight = (int)Math.Max(canvasHeight * scale, 1.0);

            return(IconResizer.ResizeImage(sourceImage, resizeWidth, resizeHeight, canvasWidth, canvasHeight));
        }
コード例 #2
0
        /// <summary>
        /// Exports the currently set image to a file
        /// Saves image as png and applies all effects to the image before saving
        /// </summary>
        public void ExportImage()
        {
            if (_workingImage == null || string.IsNullOrEmpty(_workingImagePath))
            {
                return;
            }

            const string ResizedImageSuffix = "_resized";
            const string PngExtension       = ".png";

            using (var resizedImage = ScaleImage(_workingImage, _imageScale))
                using (var invertedImage = _invertColor ? InvertImage(resizedImage) : resizedImage)
                {
                    var resizedImageName = System.IO.Path.GetFileNameWithoutExtension(_workingImagePath) + ResizedImageSuffix + PngExtension;
                    var resizedImagePath = System.IO.Path.Join(System.IO.Path.GetDirectoryName(_workingImagePath), resizedImageName);

                    IconResizer.SaveImagePng(invertedImage, resizedImagePath);
                }
        }
コード例 #3
0
 /// <summary>
 /// Inverts the colors of the image
 /// </summary>
 /// <param name="sourceImage"></param>
 /// <returns></returns>
 private static Image <Rgba32> InvertImage(Image <Rgba32> sourceImage)
 {
     return(IconResizer.InvertImage(sourceImage));
 }