当前位置: 代码迷 >> .NET相关 >> C# 画图,该怎么解决
  详细解决方案

C# 画图,该怎么解决

热度:339   发布时间:2016-04-24 03:04:10.0
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在一起 
------解决方案--------------------
你这这样行不行呀?
  相关解决方案