zoukankan
html css js c++ java
绘制合成图(进行中...)
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.IO;
using
System.Drawing;
using
System.Drawing.Drawing2D;
namespace
DrawGraphic
{
public
class
DrawProduct
{
/**/
///
<summary>
///
construct(s) function
///
</summary>
public
DrawProduct()
{
}
/**/
///
<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)
{
//
System.Web.HttpServerUtility
//
System.Web.HttpContext.Current.Server.MapPath();
Image typeImage
=
null
;
//
底图
Image srcImage
=
null
;
int
W
=
0
;
switch
(model)
{
case
"
TS
"
:
{
if
(product_src.Length
>
0
)
{
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
)
{
g.DrawImage(srcImage,
128
+
prod_left,
160
+
prod_top, W,
128
);
}
if
(txt_context.Length
>
0
)
{
//
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
"
:
{
//
图片切,绘制三个面
break
;
}
case
"
MM
"
:
{
break
;
}
case
"
PM
"
:
{
break
;
}
default
:
{
break
;
}
}
}
}
}
查看全文
相关阅读:
override new virtual 的比较
c#页面无内容解决方案
插入排序
排序算法(转)
treenode遍历文件夹
案例篇(1)
索引器(转)
迭代器的实现
抽象类和接口的区别
索引器与迭代器,属性的区别
原文地址:https://www.cnblogs.com/sjett/p/449302.html
最新文章
[你必须知道的.NET] 第八回:品味类型值类型与引用类型(上)-内存有理(转载)
软件工程阅读(中英文对照)之系统性能评价
[你必须知道的.NET] 第六回:深入浅出关键字base和this (转载)
[你必须知道的.NET] 第二回:对抽象编程:接口和抽象类(转载)
[你必须知道的.NET] 第一回:恩怨情仇:is和as (转载)
[你必须知道的.NET] 第三回:历史纠葛:特性和属性(转载)
[你必须知道的.NET] 开篇有益(转载)
[你必须知道的.NET] 第五回:深入浅出关键字把new说透(转载)
[你必须知道的.NET] 第四回:后来居上:class和struct (转载)
[你必须知道的.NET] 第七回:品味类型从通用类型系统开始(转载)
热门文章
堆vs栈
如何用ENVI 将Landsat TM/ETM 的热红外波段定标为温度值
ArcGIS Server 中的几个对象
javascript中的prototype
Asp.Net 不同区别的 OnClick ( onserverclick, onclientclick )
辐射定标,大气校正,辐射校正
ArcGIS Server SOAP API Overview
转ArcGIS Server Java ADF 案例教程
对象的位置
Endpoint Overview
Copyright © 2011-2022 走看看