基本&用于VB(5或.NET)的简单图像处理库

时间:2011-09-03 14:24:46

标签: vb.net image image-editing

这个主题在Stack Overflow上多次被触及,但我的搜索仍然没有给我一个答案。

我正在寻找一个简单易用,非常基本的图像编辑库。我需要做的就是检查jpeg和png文件的大小,并将它们旋转90°的倍数。

我可以在VB.NET中开发我的应用程序,或者最好是VB5,我没有使用任何其他库。

我尝试了高级图像库(基于免费图像库),但我无法正确注册dll,我担心在分发应用程序时我也会遇到问题。

有什么更简单的东西吗?如果它不是免费的,只要费用合理,就可以了。

感谢您的帮助和道歉,如果答案已经在其他地方并且我看不到它

1 个答案:

答案 0 :(得分:1)

在.NET中,你可以在没有外部库的情况下进行旋转;如果您可以在.NET中编写代码并在此处使用.NET Framework原语(例如C#):

public static Bitmap RotateImage(Image image, PointF offset, float angle)
{
 int R1, R2;
 R1 = R2 = 0;
 if (image.Width > image.Height)
        R2 = image.Width - image.Height;
 else
        R1 = image.Height-image.Width;

 if (image == null)
        throw new ArgumentNullException("image");

 //create a new empty bitmap to hold rotated image
 Bitmap rotatedBmp = new Bitmap(image.Width +R1+40, image.Height+R2+40);
 rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);

 //make a graphics object from the empty bitmap
 Graphics g = Graphics.FromImage(rotatedBmp);

 //Put the rotation point in the center of the image
 g.TranslateTransform(offset.X + R1/2+20, offset.Y + R2/2+20);

 //rotate the image
 g.RotateTransform(angle);

 //move the image back
 g.TranslateTransform(-offset.X - R1 / 2-20, -offset.Y - R2 / 2-20);

 //draw passed in image onto graphics object 
 g.DrawImage(image, new PointF(R1 / 2+20, R2 / 2+20));

 return rotatedBmp;
}