This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-207: ResizeBilinear filter can support more pixel formats
- Loading branch information
1 parent
5223b82
commit ec594cf
Showing
7 changed files
with
560 additions
and
225 deletions.
There are no files selected for viewing
193 changes: 113 additions & 80 deletions
193
Sources/Accord.Imaging/AForge.Imaging/Filters/Base classes/BaseResizeFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,113 @@ | ||
// AForge Image Processing Library | ||
// AForge.NET framework | ||
// | ||
// Copyright © Andrew Kirillov, 2005-2008 | ||
// [email protected] | ||
// | ||
|
||
namespace Accord.Imaging.Filters | ||
{ | ||
using System; | ||
using System.Drawing; | ||
using System.Drawing.Imaging; | ||
|
||
/// <summary> | ||
/// Base class for image resizing filters. | ||
/// </summary> | ||
/// | ||
/// <remarks><para>The abstract class is the base class for all filters, | ||
/// which implement image rotation algorithms.</para> | ||
/// </remarks> | ||
/// | ||
public abstract class BaseResizeFilter : BaseTransformationFilter | ||
{ | ||
/// <summary> | ||
/// New image width. | ||
/// </summary> | ||
protected int newWidth; | ||
|
||
/// <summary> | ||
/// New image height. | ||
/// </summary> | ||
protected int newHeight; | ||
|
||
/// <summary> | ||
/// Width of the new resized image. | ||
/// </summary> | ||
/// | ||
public int NewWidth | ||
{ | ||
get { return newWidth; } | ||
set { newWidth = Math.Max( 1, value ); } | ||
} | ||
|
||
/// <summary> | ||
/// Height of the new resized image. | ||
/// </summary> | ||
/// | ||
public int NewHeight | ||
{ | ||
get { return newHeight; } | ||
set { newHeight = Math.Max( 1, value ); } | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BaseResizeFilter"/> class. | ||
/// </summary> | ||
/// | ||
/// <param name="newWidth">Width of the new resized image.</param> | ||
/// <param name="newHeight">Height of the new resize image.</param> | ||
/// | ||
protected BaseResizeFilter( int newWidth, int newHeight ) | ||
{ | ||
this.newWidth = newWidth; | ||
this.newHeight = newHeight; | ||
} | ||
|
||
/// <summary> | ||
/// Calculates new image size. | ||
/// </summary> | ||
/// | ||
/// <param name="sourceData">Source image data.</param> | ||
/// | ||
/// <returns>New image size - size of the destination image.</returns> | ||
/// | ||
protected override System.Drawing.Size CalculateNewImageSize( UnmanagedImage sourceData ) | ||
{ | ||
return new Size( newWidth, newHeight ); | ||
} | ||
} | ||
} | ||
// AForge Image Processing Library | ||
// AForge.NET framework | ||
// | ||
// Copyright © Andrew Kirillov, 2005-2008 | ||
// [email protected] | ||
// | ||
// Accord Imaging Library | ||
// The Accord.NET Framework | ||
// http://accord-framework.net | ||
// | ||
// Copyright © César Souza, 2009-2017 | ||
// cesarsouza at gmail.com | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
// | ||
|
||
namespace Accord.Imaging.Filters | ||
{ | ||
using System; | ||
using System.Drawing; | ||
using System.Drawing.Imaging; | ||
|
||
/// <summary> | ||
/// Base class for image resizing filters. | ||
/// </summary> | ||
/// | ||
/// <remarks><para>The abstract class is the base class for all filters, | ||
/// which implement image rotation algorithms.</para> | ||
/// </remarks> | ||
/// | ||
public abstract class BaseResizeFilter : BaseTransformationFilter | ||
{ | ||
/// <summary> | ||
/// New image width. | ||
/// </summary> | ||
/// | ||
protected int newWidth; | ||
|
||
/// <summary> | ||
/// New image height. | ||
/// </summary> | ||
/// | ||
protected int newHeight; | ||
|
||
/// <summary> | ||
/// Width of the new resized image. | ||
/// </summary> | ||
/// | ||
public int NewWidth | ||
{ | ||
get { return newWidth; } | ||
set | ||
{ | ||
if (value <= 0) | ||
throw new ArgumentOutOfRangeException("Value must be higher than zero."); | ||
this.newWidth = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Height of the new resized image. | ||
/// </summary> | ||
/// | ||
public int NewHeight | ||
{ | ||
get { return newHeight; } | ||
set | ||
{ | ||
if (value <= 0) | ||
throw new ArgumentOutOfRangeException("Value must be higher than zero."); | ||
this.newHeight = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BaseResizeFilter"/> class. | ||
/// </summary> | ||
/// | ||
/// <param name="newWidth">Width of the new resized image.</param> | ||
/// <param name="newHeight">Height of the new resize image.</param> | ||
/// | ||
protected BaseResizeFilter(int newWidth, int newHeight) | ||
{ | ||
this.NewWidth = newWidth; | ||
this.NewHeight = newHeight; | ||
} | ||
|
||
/// <summary> | ||
/// Calculates new image size. | ||
/// </summary> | ||
/// | ||
/// <param name="sourceData">Source image data.</param> | ||
/// | ||
/// <returns>New image size - size of the destination image.</returns> | ||
/// | ||
protected override System.Drawing.Size CalculateNewImageSize(UnmanagedImage sourceData) | ||
{ | ||
return new Size(newWidth, newHeight); | ||
} | ||
} | ||
} |
Oops, something went wrong.