读书人

C# 画图,该如何处理

发布时间: 2013-01-11 11:57:35 作者: rapoo

C# 画图
C# 画图,该如何处理
运行后,为什么会这样啊???
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace mange22
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form_Paint(object sender, PaintEventArgs e)
{
//以原始大小画图像
Image image = Image.FromFile("ss.gif");
e.Graphics.DrawImage(image,0,0);
e.Graphics.TranslateTransform(image.Width,image.Height*2+10);//平移坐标
e.Graphics.RotateTransform(180.0f);//旋转坐标将原点坐标旋转到指定的角度
e.Graphics.DrawImage(image,0,0);
Point[] points = { new Point(0,0),new Point(20,100)};
e.Graphics.TransformPoints(CoordinateSpace.Page,CoordinateSpace.World,points);
e.Graphics.DrawLine(new Pen(Color.Red,3),points[0],points[1]);
e.Graphics.ResetTransform();//重置为单位矩阵
e.Graphics.ScaleTransform(0.5f,1.0f);//缩放
e.Graphics.DrawImageUnscaled(image,0,150);

}
}

}

[解决办法]
你那个ss.gif文件没找到吧,和程序放在一起了吗?

[解决办法]
和程序放在一起呀,你里面用mage.FromFile("ss.gif")获取的,这个就相当于相对路径。
[解决办法]

Image image = Image.FromFile(Application.Startuppath+"\\ss.gif");
把ss.gif 放到debug文件夹内
也就是和mange22.exe在一起
[解决办法]
你这这样行不行呀?

读书人网 >C++ Builder

热点推荐