开发者

Basic & easy image manipulation library for VB (5 or .NET)

开发者 https://www.devze.com 2023-04-02 00:08 出处:网络
this topic has been touched multiple times on Stack Overflow, but my search still did not give me an answer.

this topic has been touched multiple times on Stack Overflow, but my search still did not give me an answer.

I'm looking for a SIMPLE and easy to use, very basic, image editing library. All I need to do is check the size of jp开发者_如何转开发eg and png files and rotate them by multiples of 90°.

I can develop my app in VB.NET or preferably VB5 and I'm not using any other library.

I tried the Advanced Image Library (based on Free Image Library), but I can't get the dll to correctly register and I'm afraid that I will also have problems when distributing the application.

Is there something simpler? If it's not free it's fine, as long as the cost is reasonable.

Thanks for your help and my apologies if the answer was already somewhere else and I could not see it


in .NET you can do rotation without external libraries; if you can code in .NET do it and use .NET Framework primitives here for example (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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号