我见过很多人试图编写自己的图像转换技术。它通常看起来非常复杂,并最终使用GDI +函数调用,并操纵图像的位。这让我想知道如果我在保存图像时错过了.NET的图像转换调用的简单性。这里是我的代码:是否足够使用.NET Image Conversion?
Bitmap tempBmp = new Bitmap("c:\temp\img.jpg");
Bitmap bmp = new Bitmap(tempBmp, 800, 600);
bmp.Save(c:\temp\img.bmp, //extension depends on format
ImageFormat.Bmp) //These are all the ImageFormats I allow conversion to within the program. Ignore the syntax for a second ;)
ImageFormat.Gif) //or
ImageFormat.Jpeg) //or
ImageFormat.Png) //or
ImageFormat.Tiff) //or
ImageFormat.Wmf) //or
ImageFormat.Bmp)//or
);
这就是我在图像转换中所做的一切。只需设置图像保存位置,并将其传递给ImageFormat类型即可。我已经测试了它的最佳效果,但是我想知道如果我在这个简单的格式转换中丢失了什么,或者如果这足够了?
+1回答。只是想指出的是,SmoothingMode不会影响图像缩放,它会影响draigwng基元如线条,椭圆等。 – 2010-04-20 19:33:23