Former-commit-id: 73ae6ec1660e63d396408640372076701e251acc Former-commit-id: 2ee1d724789b6fe61aff90450ba4ed6efaf967e3pull/17/head
@ -0,0 +1 @@ |
|||||
|
5d446f64d0636f6ad7e9f82625eeff89ef394fe2 |
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 15 KiB |
@ -0,0 +1 @@ |
|||||
|
56cbc3371def2882d1ead5d4d2456550f2b8d72c |
||||
|
After Width: | Height: | Size: 46 KiB |
@ -0,0 +1,90 @@ |
|||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
// <copyright file="Gamma.cs" company="James South">
|
||||
|
// Copyright (c) James South.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
// <summary>
|
||||
|
// Encapsulates methods to change the alpha component of the image to effect its luminance.
|
||||
|
// </summary>
|
||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace ImageProcessor.Processors |
||||
|
{ |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Drawing; |
||||
|
|
||||
|
using ImageProcessor.Common.Exceptions; |
||||
|
using ImageProcessor.Imaging.Helpers; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Encapsulates methods to change the gamma component of the image to effect its luminance.
|
||||
|
/// </summary>
|
||||
|
public class Gamma : IGraphicsProcessor |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Gamma"/> class.
|
||||
|
/// </summary>
|
||||
|
public Gamma() |
||||
|
{ |
||||
|
this.Settings = new Dictionary<string, string>(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the dynamic parameter.
|
||||
|
/// </summary>
|
||||
|
public dynamic DynamicParameter |
||||
|
{ |
||||
|
get; |
||||
|
set; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets any additional settings required by the processor.
|
||||
|
/// </summary>
|
||||
|
public Dictionary<string, string> Settings |
||||
|
{ |
||||
|
get; |
||||
|
set; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Processes the image.
|
||||
|
/// </summary>
|
||||
|
/// <param name="factory">
|
||||
|
/// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
|
||||
|
/// the image to process.
|
||||
|
/// </param>
|
||||
|
/// <returns>
|
||||
|
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
|
||||
|
/// </returns>
|
||||
|
public Image ProcessImage(ImageFactory factory) |
||||
|
{ |
||||
|
Bitmap newImage = null; |
||||
|
Image image = factory.Image; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
float value = this.DynamicParameter; |
||||
|
|
||||
|
newImage = new Bitmap(image); |
||||
|
newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); |
||||
|
newImage = Adjustments.Gamma(newImage, value); |
||||
|
|
||||
|
image.Dispose(); |
||||
|
image = newImage; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
if (newImage != null) |
||||
|
{ |
||||
|
newImage.Dispose(); |
||||
|
} |
||||
|
|
||||
|
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex); |
||||
|
} |
||||
|
|
||||
|
return image; |
||||
|
} |
||||
|
} |
||||
|
} |
||||