我有一个有两个点的图像,对齐如下:
|----------------|
| |
| . |
| |
| . |
| |
|----------------|
Run Code Online (Sandbox Code Playgroud)
我有两个点的X,Y坐标,我需要将图像旋转X度,所以它看起来像这样:
|----------------|
| |
| |
| . . |
| |
| |
|----------------|
Run Code Online (Sandbox Code Playgroud)
基本上所以他们在彼此旁边对齐,这是什么数学?(C#中的代码示例会更好但不是必需的)
我有动画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#应用程序,我必须用它的iamge旋转整个picturebox,我使用rotateFlip()方法,但它只支持90,180,270度,我希望它1度
我刚刚经历了一些试图找出如何使图像均匀旋转的东西.这有效,但现在它是剪辑,我不知道如何让它停止...我正在使用这个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) 如何旋转图像然后移动到左上角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)