Hello,
I am dealing with images in my project. I am giving some angle and my Image should rotate in that angle. But It only rotate in multiples of 90 as I am using TransformedBitmap.
So please help me for rotating image in any angle and after rotation new image will be saved.
thanks in advanced.
Source code is:-
Image image = new Image();
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.UriSource = new Uri(_DataSource.BackgroundImageFullPath);
bitmapImage.EndInit();
image.Source = bitmapImage;
BitmapSource img = (BitmapSource)(image.Source);
//rotate tif and save
CachedBitmap cache = new CachedBitmap(img, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
TransformedBitmap tb = new TransformedBitmap(cache, new RotateTransform(imgAngle));
TiffBitmapEncoder encoder = new TiffBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(tb));
using (FileStream file = File.OpenWrite(_DataSource.BackgroundImageFullPath))
{
encoder.Save(file);
}
Hussam BarouqaPosted Jul 6, 2017, 10:51 AM
You could use a professional toolkit like LEADTOOLS which has a wide range of image processing classes and methods, including rotation of images with high resolution.
RasterImage image = codecs.Load("inputimage.tif");
float rotationAngle = 45; //degrees
RotateCommand command = new RotateCommand(rotationAngle * 100, RotateCommandFlags.Bicubic, new RasterColor(255, 255, 255));
command.Run(image);
image = codecs.Save(image, "outputimage.tif", RasterImageFormat.TifLzw, 24);
Rajkiran SwainPosted Jun 28, 2017, 11:53 AM
Manikandan MurugesanPosted Jun 28, 2017, 10:16 AM
Sundaram SubramanianPosted Jun 28, 2017, 8:11 AM