相关疑难解决方法(0)

旋转图像数学(C#)

我有一个有两个点的图像,对齐如下:

|----------------|
|                |
|    .           |
|                |
|          .     |
|                |
|----------------|
Run Code Online (Sandbox Code Playgroud)

我有两个点的X,Y坐标,我需要将图像旋转X度,所以它看起来像这样:

|----------------|
|                |
|                |
|    .     .     |
|                |
|                |
|----------------|
Run Code Online (Sandbox Code Playgroud)

基本上所以他们在彼此旁边对齐,这是什么数学?(C#中的代码示例会更好但不是必需的)

c# math image rotation

10
推荐指数
2
解决办法
2万
查看次数

如何旋转任何程度的图像?

我有动画gif和我使用类来解析它的图像(帧).这堂课是:

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.IO;

public class AnimatedGif
{
    private List<AnimatedGifFrame> mImages = new List<AnimatedGifFrame>();
    public AnimatedGif(string path)
    {
        Image img = Image.FromFile(path);
        int frames = img.GetFrameCount(FrameDimension.Time);
        if (frames <= 1) throw new ArgumentException("Image not animated");
        byte[] times = img.GetPropertyItem(0x5100).Value;
        int frame = 0;
        for (; ; )
        {
            int dur = BitConverter.ToInt32(times, 4 * frame);
            mImages.Add(new AnimatedGifFrame(new Bitmap(img), dur));
            if (++frame >= frames) break;
            img.SelectActiveFrame(FrameDimension.Time, frame);
        }
        img.Dispose();
    }
    public List<AnimatedGifFrame> Images { …
Run Code Online (Sandbox Code Playgroud)

c#

10
推荐指数
4
解决办法
3万
查看次数

在C#中如何用图像旋转图片框?

我正在开发C#应用程序,我必须用它的iamge旋转整个picturebox,我使用rotateFlip()方法,但它只支持90,180,270度,我希望它1度

c# winforms

7
推荐指数
1
解决办法
3万
查看次数

在C#中旋转图像时如何防止剪裁?

我刚刚经历了一些试图找出如何使图像均匀旋转的东西.这有效,但现在它是剪辑,我不知道如何让它停止...我正在使用这个rotateImage方法:

public static Image RotateImage(Image img, float rotationAngle)
    {
        //create an empty Bitmap image
        Bitmap bmp = new Bitmap(img.Width, img.Height);

        //turn the Bitmap into a Graphics object
        Graphics gfx = Graphics.FromImage(bmp);

        //now we set the rotation point to the center of our image
        gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);

        //now rotate the image
        gfx.RotateTransform(rotationAngle);

        gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2);

        //set the InterpolationMode to HighQualityBicubic so to ensure a high
        //quality image once it is transformed to the specified size …
Run Code Online (Sandbox Code Playgroud)

c# image clipping rotation

2
推荐指数
3
解决办法
6689
查看次数

如何旋转图像然后移动到左上角0,0而不切断图像

如何旋转图像然后移动到左上角0,0而不切断图像.

请阅读代码中的注释.我陷入了第3步,我认为使用三角法应该能够解决这个问题.

谢谢

private Bitmap RotateImage(Bitmap b, float angle)
{
    //create a new empty bitmap to hold rotated image
    Bitmap returnBitmap = new Bitmap(b.Width, b.Height);
    //make a graphics object from the empty bitmap
    Graphics g = Graphics.FromImage(returnBitmap);
    //STEP 1 move rotation point to top left
    g.TranslateTransform((float)0, (float)0);
    //STEP 2 rotate
    g.RotateTransform(angle);
    //STEP 3 move image back to top left without cutting off the image
    //SOME trigonometry calculation here
    int newY = b.Height;
    g.TranslateTransform(-(float)0, -newY);
    //draw passed in image onto graphics …
Run Code Online (Sandbox Code Playgroud)

c# gdi+

1
推荐指数
1
解决办法
3628
查看次数

标签 统计

c# ×5

image ×2

rotation ×2

clipping ×1

gdi+ ×1

math ×1

winforms ×1