Browse Source

Finishing error handling

Former-commit-id: c9850ccb110029d9f8b4d774afdabe620ec5bd6b
pull/17/head
James South 12 years ago
parent
commit
527ffc5e1b
  1. 9
      src/ImageProcessor/Processors/AutoRotate.cs
  2. 9
      src/ImageProcessor/Processors/BackgroundColor.cs
  3. 11
      src/ImageProcessor/Processors/Format.cs
  4. 13
      src/ImageProcessor/Processors/Quality.cs

9
src/ImageProcessor/Processors/AutoRotate.cs

@ -11,8 +11,11 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Imaging; using ImageProcessor.Imaging;
/// <summary> /// <summary>
@ -93,7 +96,11 @@ namespace ImageProcessor.Processors
image = newImage; image = newImage;
} }
} }
catch catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
finally
{ {
if (newImage != null) if (newImage != null)
{ {

9
src/ImageProcessor/Processors/BackgroundColor.cs

@ -10,9 +10,12 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
/// <summary> /// <summary>
/// Changes the background color of an image. /// Changes the background color of an image.
/// </summary> /// </summary>
@ -68,7 +71,11 @@ namespace ImageProcessor.Processors
image.Dispose(); image.Dispose();
image = newImage; image = newImage;
} }
catch catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
finally
{ {
if (newImage != null) if (newImage != null)
{ {

11
src/ImageProcessor/Processors/Format.cs

@ -10,8 +10,11 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Imaging.Formats; using ImageProcessor.Imaging.Formats;
/// <summary> /// <summary>
@ -56,9 +59,17 @@ namespace ImageProcessor.Processors
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns> /// </returns>
public Image ProcessImage(ImageFactory factory) public Image ProcessImage(ImageFactory factory)
{
try
{ {
ISupportedImageFormat format = this.DynamicParameter; ISupportedImageFormat format = this.DynamicParameter;
factory.Format(format); factory.Format(format);
}
catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
return factory.Image; return factory.Image;
} }
} }

13
src/ImageProcessor/Processors/Quality.cs

@ -11,8 +11,13 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
#region Using #region Using
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
#endregion #endregion
/// <summary> /// <summary>
@ -57,8 +62,16 @@ namespace ImageProcessor.Processors
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns> /// </returns>
public Image ProcessImage(ImageFactory factory) public Image ProcessImage(ImageFactory factory)
{
try
{ {
factory.CurrentImageFormat.Quality = this.DynamicParameter; factory.CurrentImageFormat.Quality = this.DynamicParameter;
}
catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
return factory.Image; return factory.Image;
} }
} }

Loading…
Cancel
Save