Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static Bitmap RotateImage(Image image, PointF offset, float angle)
- {
- var rotatedBmp = new Bitmap(image.Width, image.Height);
- rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
- var g = Graphics.FromImage(rotatedBmp);
- g.TranslateTransform(offset.X, offset.Y);
- g.RotateTransform(angle);
- g.TranslateTransform(-offset.X, -offset.Y);
- g.DrawImage(image, new PointF(0, 0));
- return rotatedBmp;
- }
- private void buttonRotate_Click(object sender, EventArgs e)
- {
- Cursor = Cursors.WaitCursor;
- float angle = (float) Convert.ToDouble(textBoxAngleRotate.Text);
- PointF offset = new PointF((float) Convert.ToSingle(
- textBoxOffsetRotateX.Text) , (float) Convert.ToSingle(textBoxOffsetRotateY.
- Text));
- bmpAsli = (Bitmap)pictureBoxInput.Image;
- bmpHasil = new Bitmap(bmpAsli.Width, bmpAsli.Height);
- bmpHasil = RotateImage(bmpAsli, offset, angle);
- pictureBoxOutput.Image = bmpHasil;
- Cursor = Cursors.Default;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement