我想问一下如何在图像上移动文本。实际上,我正在为此设计一个在线设计衬衫网站,使用户可以在图像上添加文本。用户如何调整图片上的文字位置。这是我的代码,它可以正常工作并且文本写在图像上,但是我们不能使用鼠标光标在图像上移动它。友善的帮助
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
namespace roughly
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string value = Request.Form["TextBox1"];
Bitmap bitMapImage = new
System.Drawing.Bitmap(Server.MapPath("dallen.jpg"));
Graphics graphicImage = Graphics.FromImage(bitMapImage);
graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
graphicImage.DrawString (value,
new Font("Arial", 12, FontStyle.Bold),
SystemBrushes.WindowText, new Point(250, 300));
Response.ContentType = "image/jpeg";
bitMapImage.Save(Response.OutputStream, ImageFormat.Jpeg);
graphicImage.Dispose();
bitMapImage.Dispose();
}
}
}
最佳答案
您可能正在重新发明轮子,为什么不试试这个呢?
http://jqueryui.com/draggable/