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
;
}
}
}
}
}
查看全文
相关阅读:
Android集成科大讯飞SDK语音听写及语音合成功能实现
Android开发中一些常见的问题解决方案
Android混淆配置文件规范
android第三方分享之友盟社会化组件
android一些常用的代码2(收藏)
svn
ubuntu 解决中文zip乱码问题
android优秀Github源码整理
linux清理内存
cocos2d-x图层相关 锚点
原文地址:https://www.cnblogs.com/sjett/p/449302.html
最新文章
HTML中tr,th和td的区别
如何清除网络共享文件夹的记忆帐号和密码
适配全面屏手机尺寸
要学习的内容 (一)
Goals100
My English Dictionary
关于图层
Mac Virtual System On Windows
win10U盘 安装
二进制通用公式
热门文章
转:正在发生或可能发生的变化,将影响未来
应用锁屏 /解锁 操作监听
2016.11.30
2016.11.15
双11 经典思想理论汇总
2016.11.9
Java字符拼成图片(image-ASCII)(非原创)
JavaScript中一个方法同时发送两个ajax请求问题
解决Ajax异步请求中传数组参数,后台无法接收问题
关于java输出流中flush方法的用法
Copyright © 2011-2022 走看看