From 23710bdf7aea5891f9c29ed762b3ed9f85a13a15 Mon Sep 17 00:00:00 2001 From: Logan Saso Date: Tue, 8 Mar 2016 19:25:47 -0800 Subject: [PATCH] Removed useless code --- Artemis/Artemis/App.xaml | 46 +++++++++---------- .../Razer/Utilities/RazerUtilities.cs | 35 +------------- Artemis/Artemis/Utilities/ImageUtilities.cs | 38 --------------- 3 files changed, 25 insertions(+), 94 deletions(-) diff --git a/Artemis/Artemis/App.xaml b/Artemis/Artemis/App.xaml index 110eccc23..bae7d6958 100644 --- a/Artemis/Artemis/App.xaml +++ b/Artemis/Artemis/App.xaml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - + xmlns:artemis="clr-namespace:Artemis" + DispatcherUnhandledException="Application_DispatcherUnhandledException" + ShutdownMode="OnExplicitShutdown"> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs b/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs index cc33c32d5..07c7a17d7 100644 --- a/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs +++ b/Artemis/Artemis/KeyboardProviders/Razer/Utilities/RazerUtilities.cs @@ -1,6 +1,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; +using Artemis.Utilities; using Corale.Colore.Razer.Keyboard.Effects; namespace Artemis.KeyboardProviders.Razer.Utilities @@ -11,7 +12,7 @@ namespace Artemis.KeyboardProviders.Razer.Utilities { var keyboardGrid = Custom.Create(); if (b.Width > width || b.Height > height) - b = ResizeImage(b, width, height); + b = ImageUtilities.ResizeImage(b, width, height); for (var y = 0; y < b.Height; y++) for (var x = 0; x < b.Width; x++) @@ -19,37 +20,5 @@ namespace Artemis.KeyboardProviders.Razer.Utilities return keyboardGrid; } - - /// - /// Resize the image to the specified width and height. - /// - /// The image to resize. - /// The width to resize to. - /// The height to resize to. - /// The resized image. - public static Bitmap ResizeImage(Image image, int width, int height) - { - var destRect = new Rectangle(0, 0, width, height); - var destImage = new Bitmap(width, height); - - destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); - - using (var graphics = Graphics.FromImage(destImage)) - { - graphics.CompositingMode = CompositingMode.SourceCopy; - graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; - graphics.SmoothingMode = SmoothingMode.HighQuality; - graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - - using (var wrapMode = new ImageAttributes()) - { - wrapMode.SetWrapMode(WrapMode.TileFlipXY); - graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); - } - } - - return destImage; - } } } \ No newline at end of file diff --git a/Artemis/Artemis/Utilities/ImageUtilities.cs b/Artemis/Artemis/Utilities/ImageUtilities.cs index 51a0490e4..64537a075 100644 --- a/Artemis/Artemis/Utilities/ImageUtilities.cs +++ b/Artemis/Artemis/Utilities/ImageUtilities.cs @@ -78,44 +78,6 @@ namespace Artemis.Utilities return result; } - /// - /// Saves an image as a jpeg image, with the given quality - /// - /// Path to which the image would be saved. - /// - /// An integer from 0 to 100, with 100 being the - /// highest quality - /// - /// - /// An invalid value was entered for image quality. - /// - public static void SaveJpeg(string path, Image image, int quality) - { - //ensure the quality is within the correct range - if ((quality < 0) || (quality > 100)) - { - //create the error message - var error = - string.Format( - "Jpeg image quality must be between 0 and 100, with 100 being the highest quality. A value of {0} was specified.", - quality); - //throw a helpful exception - throw new ArgumentOutOfRangeException(error); - } - - //create an encoder parameter for the image quality - var qualityParam = new EncoderParameter(Encoder.Quality, quality); - //get the jpeg codec - var jpegCodec = GetEncoderInfo("image/jpeg"); - - //create a collection of all parameters that we will pass to the encoder - var encoderParams = new EncoderParameters(1); - //set the quality parameter for the codec - encoderParams.Param[0] = qualityParam; - //save the image using the codec and the parameters - image.Save(path, jpegCodec, encoderParams); - } - /// /// Returns the image codec with the given mime type ///