WEB开发网
开发学院WEB开发ASP.NET c#给图片添加文字 阅读

c#给图片添加文字

 2012-11-16 20:54:13 来源:WEB开发网   
核心提示: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using Syst

 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.IO;
using System.Threading;
using System.Drawing.Imaging;
/* Author : IT
* Date: 2011-11-13 14:52:53
* Blog: www.chenpan.name
*/
namespace WaterImage
{
public partial class Form2 : Form
{
Image imgWeight;

public Form2()
{
InitializeComponent();
}
/// <summary>
/// 从数据库中加载二进制图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
string strSql = "Select Top 1 FileContent From Sys_FileSave";

Byte[] byteImage = new Byte[0];

byteImage = (Byte[])(DbHelperSQL.GetSingle(strSql));

MemoryStream stmBLOBData = new MemoryStream(byteImage);

imgWeight = Image.FromStream(stmBLOBData); pictureBox1.Image = imgWeight;
}
/// <summary>
/// 在原图片基础上加载文字水印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
Graphics GImage = Graphics.FromImage(imgWeight);

addWatermarkText(GImage, "重量为60.00吨", "WM_BOTTOM_RIGHT", imgWeight.Width, imgWeight.Height);

pictureBox1.Image = imgWeight;
}
/// <summary>
/// 在原图片基础上加载图片水印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
Graphics GImage = Graphics.FromImage(imgWeight);

addWatermarkImage(GImage, @"C:\Documents and Settings\Administrator\桌面\Mark.png", "WM_TOP_LEFT", imgWeight.Width, imgWeight.Height);

pictureBox1.Image = imgWeight;
}
/// <summary>
/// 生成图片缩略图
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, EventArgs e)
{
GreateMiniImage(@"C:\Documents and Settings\Administrator\桌面\Source.jpg", @"C:\Documents and Settings\Administrator\桌面\Small.png", 100, 200);
}

/// <summary>
/// 加水印文字
/// </summary>
/// <param name="picture">imge 对象</param>
/// <param name="_watermarkText">水印文字内容</param>
/// <param name="_watermarkPosition">水印位置</param>
/// <param name="_width">被加水印图片的宽</param>
/// <param name="_height">被加水印图片的高</param>

1 2 3 4  下一页

Tags:图片 添加 文字

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接