你試過來進行圖像處理嗎?公司最近進行的一個項目
雖說我還是江湖嫩手
using System
using System
using System
private void AddTextToImg(string fileName
{
if(!File
{
throw new FileNotFoundException(
}
if( text == string
{
return;
}
//還需要判斷文件類型是否為圖像類型
System
Bitmap bitmap = new Bitmap(image
Graphics g = Graphics
float fontSize =
float textWidth = text
//下面定義一個矩形區域
float rectX =
float rectY =
float rectWidth = text
float rectHeight = fontSize+
//聲明矩形域
RectangleF textArea = new RectangleF(rectX
Font font = new Font(
Brush whiteBrush = new SolidBrush(Color
Brush blackBrush = new SolidBrush(Color
g
g
MemoryStream ms = new MemoryStream( );
//保存為Jpg類型
bitmap
//輸出處理後的圖像
Response
Response
Response
g
bitmap
image
}
調用時很簡單
AddTextToImg(
這些功能在Asp中可是奢侈品了
From:http://tw.wingwit.com/Article/program/net/201311/13828.html