0

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 jpeg 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

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Davide
  • 87
  • 13

1 Answers1

1

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;
}
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • Thanks a lot Davide! (Davide Piras? Are you from Sardinia by any chance? I'm a big time lover of the island!) Actually, VB5 would be a lot better than VB.net, as it would work on earlier versions of Windows and would not force people to download the .NET framework. On top of that, I'm a lot more proficient in the old VB and it would take me more to write the app in .NET. Thanks anyway! I'll probably end up using your solution! – Davide Sep 03 '11 at 15:38