所以我决定加入学习编写更多代码并且设法变得相当困难,因为我不知道足够的基础我认为。我已经在C中完成了一些工作,在C ++中做了一些工作,如果这有任何区别的话。
我决定根据输入调制指向某个角度的指针。我有一切工作吧让箭头旋转。到目前为止,我在pictureBox中有一个箭头bmp图像,以下代码在我构建之前不会显示任何错误。我不完全确定还有什么人可能需要知道才能提供帮助,所以现在我只需发布我的代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private Bitmap MoveImageByDesiredAngle(int original_width, int original_height, float desiredAngle)
{
Bitmap resultPicture = new Bitmap(original_width, original_height);
Graphics g = Graphics.FromImage(resultPicture);
g.TranslateTransform((float)original_width / 2, (float)original_height / 2);
g.RotateTransform(desiredAngle);
g.TranslateTransform(-(float)original_width / 2, -(float)original_height / 2);
g.DrawImage(pictureBox1.Image, new Point(0, 0));
return resultPicture;
}
private void button1_Click(object sender, EventArgs e)
{
float o;
float r;
o = float.Parse(textBox1.Text);
r = float.Parse(textBox2.Text);
float ratio;
float angle;
ratio = o / (o + r);
angle = ratio * 180;
Bitmap resultPicture = MoveImageByDesiredAngle(pictureBox3.Image.Width, pictureBox3.Image.Height, angle);
pictureBox3.Image = resultPicture;
}
}
}