using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
![](/Images/OutliningIndicators/None.gif)
namespace DrawGraphic
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
public class DrawProduct
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// construct(s) function
/// </summary>
public DrawProduct()
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
}
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 绘制产品图
/// </summary>
/// <param name="product_type">合成底图地址</param>
/// <param name="product_src">合成图片地址</param>
/// <param name="txt_context">合成文字内容</param>
/// <param name="txt_top">合成文字top坐标</param>
/// <param name="txt_left">合成文字left坐标</param>
/// <param name="prod_top">合成图片top坐标</param>
/// <param name="prod_left">合成图片left坐标</param>
/// <param name="prod_width">合成图片Width</param>
/// <param name="prod_height">合成图片Height</param>
/// <param name="txt_size">合成文字Font-Size</param>
/// <param name="resulturl">保存路径</param>
/// <param name="model">绘制何种产品,T-shirt(TS),cup(CUP),mouse-mat(MM),picture mosaic(PM)</param>
/// <returns>返回,绘制成功产品图地址</returns>
public static void drawProduct(string product_type, string product_src, string txt_context, int txt_top, int txt_left,
int prod_top, int prod_left, int prod_width, int prod_height, int txt_size, string model, string resulturl)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//System.Web.HttpServerUtility
//System.Web.HttpContext.Current.Server.MapPath();
Image typeImage = null; //底图
Image srcImage = null;
int W = 0;
switch (model)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
case "TS":
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (product_src.Length > 0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string a1 = System.Web.HttpContext.Current.Server.MapPath(product_src);
srcImage = Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(product_src)); //合成图
//指定高,宽按比例
W = srcImage.Width * 128 / srcImage.Height;
}
string a2 = System.Web.HttpContext.Current.Server.MapPath(product_type);
typeImage = Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(product_type));
Graphics g = Graphics.FromImage(typeImage);
g.SmoothingMode = SmoothingMode.AntiAlias;
//底图大小400x400, 合成图坐标起点128x160,合成图大小160x128; 高128
if (product_src.Length > 0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
g.DrawImage(srcImage, 128 + prod_left, 160 + prod_top, W, 128);
}
if (txt_context.Length > 0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//Brushes; SolidBrush s = new SolidBrush(Color)
g.DrawString(txt_context, new Font("宋体", (float)txt_size, FontStyle.Regular), SystemBrushes.WindowText, new Point(128 + txt_left, 160 + txt_top));
}
typeImage.Save(resulturl, System.Drawing.Imaging.ImageFormat.Jpeg);
g.Dispose();
srcImage.Dispose();
typeImage.Dispose();
break;
}
case "CUP":
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//图片切,绘制三个面
![](/Images/OutliningIndicators/InBlock.gif)
break;
}
case "MM":
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
break;
}
case "PM":
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](/Images/OutliningIndicators/InBlock.gif)
break;
}
default :
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
break;
}
}
}
}
}
![](/Images/OutliningIndicators/None.gif)
posted @
2006-07-12 20:20
SCADA组态软件(2D,3D)
阅读(
920)
评论()
编辑
收藏
举报