Hvorfor bliver mine billeder grimme?
Jeg vil gerne skalere mine billeder ned uden de bliver grimme. Hvordan skalere jeg unden tab og "klarhed"?private void DisplayImage( int maxDimension )
{
string imagePath = MapPath( Album.AlbumImages[ AlbumIndex ][ PictureIndex ] );
System.Drawing.Image image = new Bitmap( imagePath );
System.Drawing.Image thumbnail;
// Make pictures smaller but not larger.
if( image.PhysicalDimension.Width < maxDimension &&
image.PhysicalDimension.Height < maxDimension )
{
thumbnail = image;
}
else
{
// Aspect ratio logic provided by Bryce Jasmer.
float aspect = image.PhysicalDimension.Width / image.PhysicalDimension.Height;
if ( aspect <= 1.0 ) // Portrait
{
thumbnail = image.GetThumbnailImage(
(int)(maxDimension * aspect), maxDimension, null, new IntPtr());
}
else // Landscape
{
thumbnail = image.GetThumbnailImage(
maxDimension, (int)(maxDimension / aspect), null, new IntPtr());
}
}
thumbnail.Save( Response.OutputStream, image.);
}
