From 795d7f7e26fbd4067770ae3178acc956e2cbb4a4 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 23 Jan 2014 19:35:51 +0000 Subject: [PATCH] Remove unnecessary Image.Tag property use Former-commit-id: 468c9b2f79317e4bbd5131a3e66db0b5d5f858e4 --- src/ImageProcessor/ImageFactory.cs | 26 +++++++++--------- .../Imaging/Filters/BlackWhiteMatrixFilter.cs | 11 +++++--- .../Imaging/Filters/GothamMatrixFilter.cs | 11 +++++--- .../Imaging/Filters/GreyScaleMatrixFilter.cs | 11 +++++--- .../Imaging/Filters/HiSatchMatrixFilter.cs | 15 +++++------ .../Imaging/Filters/IMatrixFilter.cs | 15 ++++++----- .../Imaging/Filters/InvertMatrixFilter.cs | 15 +++++------ .../Imaging/Filters/LoSatchMatrixFilter.cs | 15 +++++------ .../Imaging/Filters/LomographMatrixFilter.cs | 11 +++++--- .../Imaging/Filters/PolaroidMatrixFilter.cs | 27 +++++++++---------- .../Imaging/Filters/SepiaMatrixFilter.cs | 15 +++++------ src/ImageProcessor/Processors/Alpha.cs | 3 --- src/ImageProcessor/Processors/Brightness.cs | 3 --- src/ImageProcessor/Processors/Contrast.cs | 3 --- src/ImageProcessor/Processors/Crop.cs | 3 --- src/ImageProcessor/Processors/Filter.cs | 3 --- src/ImageProcessor/Processors/Flip.cs | 3 --- src/ImageProcessor/Processors/GaussianBlur.cs | 1 - .../Processors/GaussianSharpen.cs | 1 - src/ImageProcessor/Processors/Resize.cs | 3 --- src/ImageProcessor/Processors/Rotate.cs | 1 - .../Processors/RoundedCorners.cs | 1 - src/ImageProcessor/Processors/Saturation.cs | 2 -- src/ImageProcessor/Processors/Vignette.cs | 11 +++----- src/ImageProcessor/Processors/Watermark.cs | 14 +++++----- src/ImageProcessor/Settings.StyleCop | 1 + 26 files changed, 103 insertions(+), 122 deletions(-) diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 3a0ccf6cd..c2c97ea45 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -40,6 +40,11 @@ namespace ImageProcessor /// private ImageFormat backupImageFormat; + /// + /// The memory stream for storing any input stream to prevent disposal. + /// + private MemoryStream inputStream; + /// /// Whether the image is indexed. /// @@ -131,8 +136,8 @@ namespace ImageProcessor // Set our image as the memory stream value. this.Image = Image.FromStream(memoryStream, true); - // Store the stream in the image Tag property so we can dispose of it later. - this.Image.Tag = memoryStream; + // Store the stream so we can dispose of it later. + this.inputStream = memoryStream; // Set the other properties. this.JpegQuality = DefaultJpegQuality; @@ -183,8 +188,8 @@ namespace ImageProcessor // Set our image as the memory stream value. this.Image = Image.FromStream(memoryStream, true); - // Store the stream in the image Tag property so we can dispose of it later. - this.Image.Tag = memoryStream; + // Store the stream so we can dispose of it later. + this.inputStream = memoryStream; // Set the other properties. this.JpegQuality = DefaultJpegQuality; @@ -227,13 +232,8 @@ namespace ImageProcessor { if (this.ShouldProcess) { - MemoryStream memoryStream = (MemoryStream)this.Image.Tag; - // Set our new image as the memory stream value. - Image newImage = Image.FromStream(memoryStream, true); - - // Store the stream in the image Tag property so we can dispose of it later. - newImage.Tag = memoryStream; + Image newImage = Image.FromStream(this.inputStream, true); // Dispose and reassign the image. this.Image.Dispose(); @@ -901,10 +901,10 @@ namespace ImageProcessor if (this.Image != null) { // Dispose of the memory stream from Load and the image. - if (this.Image.Tag != null) + if (this.inputStream != null) { - ((IDisposable)this.Image.Tag).Dispose(); - this.Image.Tag = null; + this.inputStream.Dispose(); + this.inputStream = null; } this.Image.Dispose(); diff --git a/src/ImageProcessor/Imaging/Filters/BlackWhiteMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/BlackWhiteMatrixFilter.cs index ba1baf86d..0d3920b14 100644 --- a/src/ImageProcessor/Imaging/Filters/BlackWhiteMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/BlackWhiteMatrixFilter.cs @@ -1,9 +1,12 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a black and white filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { diff --git a/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs index 8f46d9f1d..ddbb92128 100644 --- a/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs @@ -1,9 +1,12 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a Gotham filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { diff --git a/src/ImageProcessor/Imaging/Filters/GreyScaleMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/GreyScaleMatrixFilter.cs index edf153994..677ac1c97 100644 --- a/src/ImageProcessor/Imaging/Filters/GreyScaleMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/GreyScaleMatrixFilter.cs @@ -1,9 +1,12 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a greyscale filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { diff --git a/src/ImageProcessor/Imaging/Filters/HiSatchMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/HiSatchMatrixFilter.cs index 21d47a463..5a8db565d 100644 --- a/src/ImageProcessor/Imaging/Filters/HiSatchMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/HiSatchMatrixFilter.cs @@ -1,17 +1,16 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a high saturated filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { #region Using - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; using System.Drawing; using System.Drawing.Imaging; #endregion diff --git a/src/ImageProcessor/Imaging/Filters/IMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/IMatrixFilter.cs index 4bd26212d..3c773000e 100644 --- a/src/ImageProcessor/Imaging/Filters/IMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/IMatrixFilter.cs @@ -1,9 +1,12 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Defines properties and methods for ColorMatrix based filters. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { @@ -15,10 +18,10 @@ namespace ImageProcessor.Imaging.Filters /// /// Defines properties and methods for ColorMatrix based filters. /// - interface IMatrixFilter + public interface IMatrixFilter { /// - /// Gets the for this filter instance. + /// Gets the for this filter instance. /// ColorMatrix Matrix { get; } diff --git a/src/ImageProcessor/Imaging/Filters/InvertMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/InvertMatrixFilter.cs index 38eaba09d..fbf8be63f 100644 --- a/src/ImageProcessor/Imaging/Filters/InvertMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/InvertMatrixFilter.cs @@ -1,17 +1,16 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add an inverted filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { #region Using - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; using System.Drawing; using System.Drawing.Imaging; #endregion diff --git a/src/ImageProcessor/Imaging/Filters/LoSatchMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/LoSatchMatrixFilter.cs index d0783db4e..dbbbcb799 100644 --- a/src/ImageProcessor/Imaging/Filters/LoSatchMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/LoSatchMatrixFilter.cs @@ -1,17 +1,16 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a low saturated filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { #region Using - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; using System.Drawing; using System.Drawing.Imaging; #endregion diff --git a/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs index 121d2a887..7d9b4ff1f 100644 --- a/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs @@ -1,9 +1,12 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a lomograph filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { diff --git a/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs index 0253e2c56..947c79f25 100644 --- a/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs @@ -1,25 +1,24 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a Polaroid filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { #region Using - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; using System.Drawing; + using System.Drawing.Drawing2D; using System.Drawing.Imaging; using ImageProcessor.Processors; - using System.Drawing.Drawing2D; #endregion /// - /// Encapsulates methods with which to add a polaroid filter to an image. + /// Encapsulates methods with which to add a Polaroid filter to an image. /// internal class PolaroidMatrixFilter : IMatrixFilter { @@ -66,12 +65,12 @@ namespace ImageProcessor.Imaging.Filters // way in to the centre. brush.WrapMode = WrapMode.Tile; brush.CenterColor = Color.FromArgb(70, 255, 153, 102); - brush.SurroundColors = new Color[] { Color.FromArgb(0, 0, 0, 0) }; + brush.SurroundColors = new[] { Color.FromArgb(0, 0, 0, 0) }; Blend blend = new Blend { - Positions = new float[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F }, - Factors = new float[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f } + Positions = new[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F }, + Factors = new[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f } }; brush.Blend = blend; @@ -88,7 +87,7 @@ namespace ImageProcessor.Imaging.Filters // Add a vignette to finish the effect. factory.Update(newImage); Vignette vignette = new Vignette(); - newImage = (Bitmap)vignette.ProcessImage(factory); + newImage = vignette.ProcessImage(factory); // Reassign the image. image.Dispose(); diff --git a/src/ImageProcessor/Imaging/Filters/SepiaMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/SepiaMatrixFilter.cs index f16e80fc4..2a35b6f50 100644 --- a/src/ImageProcessor/Imaging/Filters/SepiaMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/SepiaMatrixFilter.cs @@ -1,17 +1,16 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods with which to add a sepia filter to an image. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging.Filters { #region Using - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; using System.Drawing; using System.Drawing.Imaging; #endregion diff --git a/src/ImageProcessor/Processors/Alpha.cs b/src/ImageProcessor/Processors/Alpha.cs index acdcd9ee9..6cb1ca58c 100644 --- a/src/ImageProcessor/Processors/Alpha.cs +++ b/src/ImageProcessor/Processors/Alpha.cs @@ -122,10 +122,7 @@ namespace ImageProcessor.Processors { int alphaPercent = this.DynamicParameter; - // Don't use an object initializer here. - // ReSharper disable once UseObjectOrCollectionInitializer newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb); - newImage.Tag = image.Tag; ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = colorMatrix.Matrix11 = colorMatrix.Matrix22 = colorMatrix.Matrix44 = 1; diff --git a/src/ImageProcessor/Processors/Brightness.cs b/src/ImageProcessor/Processors/Brightness.cs index 6fc3fbe20..041d108b1 100644 --- a/src/ImageProcessor/Processors/Brightness.cs +++ b/src/ImageProcessor/Processors/Brightness.cs @@ -122,10 +122,7 @@ namespace ImageProcessor.Processors { float brightnessFactor = (float)this.DynamicParameter / 100; - // Don't use an object initializer here. - // ReSharper disable once UseObjectOrCollectionInitializer newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb); - newImage.Tag = image.Tag; ColorMatrix colorMatrix = new ColorMatrix( new float[][] diff --git a/src/ImageProcessor/Processors/Contrast.cs b/src/ImageProcessor/Processors/Contrast.cs index 01f186b2b..fbf056e46 100644 --- a/src/ImageProcessor/Processors/Contrast.cs +++ b/src/ImageProcessor/Processors/Contrast.cs @@ -126,10 +126,7 @@ namespace ImageProcessor.Processors contrastFactor++; float factorTransform = 0.5f * (1.0f - contrastFactor); - // Don't use an object initializer here. - // ReSharper disable once UseObjectOrCollectionInitializer newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb); - newImage.Tag = image.Tag; ColorMatrix colorMatrix = new ColorMatrix( new float[][] diff --git a/src/ImageProcessor/Processors/Crop.cs b/src/ImageProcessor/Processors/Crop.cs index 56a6b176d..d800a1976 100644 --- a/src/ImageProcessor/Processors/Crop.cs +++ b/src/ImageProcessor/Processors/Crop.cs @@ -144,10 +144,7 @@ namespace ImageProcessor.Processors rectangle.Height = sourceHeight - rectangle.Y; } - // Don't use an object initializer here. - // ReSharper disable once UseObjectOrCollectionInitializer newImage = new Bitmap(rectangle.Width, rectangle.Height, PixelFormat.Format32bppPArgb); - newImage.Tag = image.Tag; using (Graphics graphics = Graphics.FromImage(newImage)) { diff --git a/src/ImageProcessor/Processors/Filter.cs b/src/ImageProcessor/Processors/Filter.cs index cfdd05cb8..8f1b8d5b4 100644 --- a/src/ImageProcessor/Processors/Filter.cs +++ b/src/ImageProcessor/Processors/Filter.cs @@ -119,10 +119,7 @@ namespace ImageProcessor.Processors try { - // Don't use an object initializer here. - // ReSharper disable once UseObjectOrCollectionInitializer newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb); - newImage.Tag = image.Tag; switch ((string)this.DynamicParameter) { diff --git a/src/ImageProcessor/Processors/Flip.cs b/src/ImageProcessor/Processors/Flip.cs index 634856691..81b3cd602 100644 --- a/src/ImageProcessor/Processors/Flip.cs +++ b/src/ImageProcessor/Processors/Flip.cs @@ -134,9 +134,6 @@ namespace ImageProcessor.Processors newImage = (Bitmap)image.Clone(); - // Tag doesn't get cloned. - newImage.Tag = image.Tag; - // Flip newImage.RotateFlip(rotateFlipType); diff --git a/src/ImageProcessor/Processors/GaussianBlur.cs b/src/ImageProcessor/Processors/GaussianBlur.cs index 54b93dc9d..4a78185aa 100644 --- a/src/ImageProcessor/Processors/GaussianBlur.cs +++ b/src/ImageProcessor/Processors/GaussianBlur.cs @@ -141,7 +141,6 @@ namespace ImageProcessor.Processors Convolution convolution = new Convolution(gaussianLayer.Sigma) { Threshold = gaussianLayer.Threshold }; double[,] kernel = convolution.CreateGuassianBlurFilter(gaussianLayer.Size); newImage = convolution.ProcessKernel(newImage, kernel); - newImage.Tag = image.Tag; image.Dispose(); image = newImage; diff --git a/src/ImageProcessor/Processors/GaussianSharpen.cs b/src/ImageProcessor/Processors/GaussianSharpen.cs index df20529d2..1056940fb 100644 --- a/src/ImageProcessor/Processors/GaussianSharpen.cs +++ b/src/ImageProcessor/Processors/GaussianSharpen.cs @@ -141,7 +141,6 @@ namespace ImageProcessor.Processors Convolution convolution = new Convolution(gaussianLayer.Sigma) { Threshold = gaussianLayer.Threshold }; double[,] kernel = convolution.CreateGuassianSharpenFilter(gaussianLayer.Size); newImage = convolution.ProcessKernel(newImage, kernel); - newImage.Tag = image.Tag; image.Dispose(); image = newImage; diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs index 20d5b4476..c35539a03 100644 --- a/src/ImageProcessor/Processors/Resize.cs +++ b/src/ImageProcessor/Processors/Resize.cs @@ -348,10 +348,7 @@ namespace ImageProcessor.Processors return image; } - // Don't use an object initializer here. - // ReSharper disable once UseObjectOrCollectionInitializer newImage = new Bitmap(width, height, PixelFormat.Format32bppPArgb); - newImage.Tag = image.Tag; using (Graphics graphics = Graphics.FromImage(newImage)) { diff --git a/src/ImageProcessor/Processors/Rotate.cs b/src/ImageProcessor/Processors/Rotate.cs index c88199eb0..57e06fa2b 100644 --- a/src/ImageProcessor/Processors/Rotate.cs +++ b/src/ImageProcessor/Processors/Rotate.cs @@ -156,7 +156,6 @@ namespace ImageProcessor.Processors // Create a rotated image. newImage = this.RotateImage(image, rotateAtX, rotateAtY, angle, backgroundColor); - newImage.Tag = image.Tag; image.Dispose(); image = newImage; diff --git a/src/ImageProcessor/Processors/RoundedCorners.cs b/src/ImageProcessor/Processors/RoundedCorners.cs index 8fc056b06..ee6b0008b 100644 --- a/src/ImageProcessor/Processors/RoundedCorners.cs +++ b/src/ImageProcessor/Processors/RoundedCorners.cs @@ -175,7 +175,6 @@ namespace ImageProcessor.Processors // Create a rotated image. newImage = this.RoundCornerImage(image, radius, backgroundColor, topLeft, topRight, bottomLeft, bottomRight); - newImage.Tag = image.Tag; image.Dispose(); image = newImage; diff --git a/src/ImageProcessor/Processors/Saturation.cs b/src/ImageProcessor/Processors/Saturation.cs index 9c2099ca1..501642d32 100644 --- a/src/ImageProcessor/Processors/Saturation.cs +++ b/src/ImageProcessor/Processors/Saturation.cs @@ -137,9 +137,7 @@ namespace ImageProcessor.Processors float saturationComplementG = 0.6094f * saturationComplement; float saturationComplementB = 0.0820f * saturationComplement; - // Don't use an object initializer here. newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb); - newImage.Tag = image.Tag; ColorMatrix colorMatrix = new ColorMatrix( diff --git a/src/ImageProcessor/Processors/Vignette.cs b/src/ImageProcessor/Processors/Vignette.cs index 52dd33542..4236078e8 100644 --- a/src/ImageProcessor/Processors/Vignette.cs +++ b/src/ImageProcessor/Processors/Vignette.cs @@ -119,9 +119,7 @@ namespace ImageProcessor.Processors try { - // Don't use an object initializer here. newImage = new Bitmap(image); - newImage.Tag = image.Tag; using (Graphics graphics = Graphics.FromImage(newImage)) { @@ -146,12 +144,12 @@ namespace ImageProcessor.Processors // This has the effect of painting the far corners black and shade less on the way in to the centre. brush.WrapMode = WrapMode.Tile; brush.CenterColor = Color.FromArgb(0, 0, 0, 0); - brush.SurroundColors = new Color[] { Color.FromArgb(255, 0, 0, 0) }; + brush.SurroundColors = new[] { Color.FromArgb(255, 0, 0, 0) }; Blend blend = new Blend { - Positions = new float[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F }, - Factors = new float[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f } + Positions = new[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F }, + Factors = new[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f } }; brush.Blend = blend; @@ -180,5 +178,4 @@ namespace ImageProcessor.Processors } #endregion } -} - +} \ No newline at end of file diff --git a/src/ImageProcessor/Processors/Watermark.cs b/src/ImageProcessor/Processors/Watermark.cs index 25abe65e3..34fa8238f 100644 --- a/src/ImageProcessor/Processors/Watermark.cs +++ b/src/ImageProcessor/Processors/Watermark.cs @@ -1,9 +1,12 @@ -// ----------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // -// ----------------------------------------------------------------------- +// +// Encapsulates methods to change the alpha component of the image to effect its transparency. +// +// -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Processors { @@ -173,10 +176,7 @@ namespace ImageProcessor.Processors try { - // Don't use an object initializer here. newImage = new Bitmap(image); - newImage.Tag = image.Tag; - TextLayer textLayer = this.DynamicParameter; string text = textLayer.Text; int opacity = textLayer.Opacity; diff --git a/src/ImageProcessor/Settings.StyleCop b/src/ImageProcessor/Settings.StyleCop index 0b178ac1e..e9d49b9f2 100644 --- a/src/ImageProcessor/Settings.StyleCop +++ b/src/ImageProcessor/Settings.StyleCop @@ -2,6 +2,7 @@ behaviour + lomograph