一、图像格式的转换
string strFilePathName = ImageShow.ImageUrl;
System.Drawing.Image i = System.Drawing.Image.FromFile(strFilePathName);
//以下得到在服务器上保存的文件路径名称
string strFileName = Path.GetFileNameWithoutExtension(strFilePathName);
ImageFormat f = ImageFormat.Bmp;
switch(ddlFormat.SelectedItem.Text.ToLower())//toLower为转换为小写
i.Save(strSeverPath,f);
下面是实现在图片上写字、切割图片、拉伸和旋转
对图片的处理和显示最好放在不同的页面,负责回显示满的
比如写字,切割等按钮放在一个页面,对这些操作放在Session里面保存
比如按钮执行 Session["Add"] = true; Session["Path"] = InputFile.PostedFile.FileName是保存图片的路径,在改页面放一个图片控件比如:
genpicture.aspx这个是另一个页面,在这个页面来处理图像。
代码如下:
if(Session["Path"]!=null)
}
下面是对图片的一些基本操作画图
Bitmap b = new Bitmap(600,600);
Graphics g = Graphics.FromImage(b);//GDI+中最重要的类
g.Clear(Color.Red);
Pen p = new Pen(Color.Green,3.0f);//铅笔
g.DrawLine(p,0,0,600,600);
g.DrawLine(p,600,0,0,600);
g.DrawEllipse(p,0,0,100,100);
SolidBrush sb = new SolidBrush(Color.Blue);//固体刷
g.FillEllipse(sb,100,100,200,200);
g.FillRectangle(sb,300,300,100,100);
Font f = new Font("宋体",40);//字体
g.DrawString("哈哈,不错!",f,sb,0,300);
Point[] arrP = new Point[5];//point为基本的点
arrP[0] = new Point(200,200);
arrP[1] = new Point(200,400);
arrP[2] = new Point(500,400);
arrP[3] = new Point(500,600);
arrP[4] = new Point(300,600);
g.DrawPolygon(p,arrP);
b.Save(Response.OutputStream,ImageFormat.Gif);
相关文章:
-
2021-12-05
-
2022-01-07
-
2022-12-23
-
2021-07-21
-
2022-12-23
-
2022-12-23
-
2021-12-19
-
2022-01-15
猜你喜欢
-
2021-07-08
-
2021-05-07
-
2021-05-19
-
2021-04-09
-
2021-07-02
-
2022-12-23
相关资源
-
下载
2023-01-19
-
下载
2021-06-06
-
下载
2022-12-28
-
下载
2023-01-23