ID: 1003 - Reducir tamaño de imágen usando la clase System.Drawing.Graphics
Posted by layonman98 on Mon Feb 22 17:59:22 UTC 2010.
Language csharp
/* Función ReduceImg:
* Retorna un objeto de tipo Bitmap con al imágen enviada a través
* del parámetro img reducida al tamaño dado por los valores de
* los parámetros nWidth y nHeight.
*/
//using System;
//using System.Drawing;
private Bitmap ReduceImg( Bitmap img, int nWidth, int nHeight )
{
var result = new Bitmap( nWidth, nHeight );
using(Graphics g = Graphics.FromImage( ( Image ) result ) ){
g.DrawImage( result, nWidth, nHeight );
}
return result;
}