Jump to content
  • Advertisement
Sign in to follow this  
shadowcomplex

Getting RotateFlip to work (C#)

This topic is 3603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!