Hi,
I have been trying to flip an image vertically before saving in disk in AVI format. I really dont know why i need to flip it first before saving, any idea?
To do this currently i am performing a simple algorithm...
This works correctly but has severe performance bottleneck. I guess due to Set & Get pixel methods.
If you know a better approach and can share code with me, I will really appreciate.
Thanks,
Shailendra
I have been trying to flip an image vertically before saving in disk in AVI format. I really dont know why i need to flip it first before saving, any idea?
To do this currently i am performing a simple algorithm...
Code:
public Bitmap RotateFlip(Bitmap source, RotateFlipType change)
{
Bitmap dest = new Bitmap(source.Size.Width, source.Size.Height);
int MaxWidthIndex = source.Size.Width - 1;
int MaxHeightIndex = source.Size.Height - 1;
for (int X = 0; X < source.Size.Width; X++)
{
for (int Y = 0; Y < source.Size.Height; Y++)
{
switch (change)
{
case RotateFlipType.RotateNoneFlipY:
dest.SetPixel(MaxWidthIndex - X, Y, source.GetPixel(MaxWidthIndex - X, MaxHeightIndex - Y));
break;
default:
throw new Exception("Not implemented");
}
}
}
return dest;
}
If you know a better approach and can share code with me, I will really appreciate.
Thanks,
Shailendra
Comment