Sign in to follow this  
shadowcomplex

Getting RotateFlip to work (C#)

Recommended Posts

I'm not much of a C# whiz, so my knowledge with the system.drawing library is basically non-existent. I've got an animation tool where I need to apply rotations and mirroring to my image. The rotation code below works fine, but I can't seem to get RotateFlip to work. My guess is something stupid trivial, so please enlighten :)
//Create a new bitmap to render into
Bitmap bitmap = new Bitmap((int)cell.w, (int)cell.h);
Graphics g = Graphics.FromImage(bitmap);

//if (cell.mirror == true)
  bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);

//Perform transformations
g.TranslateTransform((float)bitmap.Width / 2, (float)bitmap.Height / 2);
g.RotateTransform(cell.rot);
g.TranslateTransform(-(float)bitmap.Width / 2, -(float)bitmap.Height / 2);

//Render to the bitmap
Rectangle rt = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
g.DrawImage(ActiveTexture, rt, cell.tx, cell.ty, cell.w, cell.h, GraphicsUnit.Pixel);


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this