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
;
}
}
}
}
}
查看全文
相关阅读:
valueOf与toString
责任链模式
Js中Symbol对象
Vue路由懒加载
updatedb命令
策略模式
Docker(3)- Centos 7.x 下 Docker 镜像加速配置
Vmware
Docker(2)- Centos 7.x 下安装 Docker
Docker(1)- 什么是 Docker
原文地址:https://www.cnblogs.com/sjett/p/449302.html
最新文章
我的《海量数据处理与大数据技术实战》出版啦!
【MySQL】面试官问我:MySQL如何实现无数据插入,有数据更新?我是这样回答的!
【Spring】使用@Profile注解实现开发、测试和生产环境的配置和切换,看完这篇我彻底会了!!
【面经】面试官问我:数据库中事务的隔离级别有哪些?各自有什么特点?然而。。。
【Nginx】如何使用自签CA配置HTTPS加密反向代理访问?看了这篇我会了!!
【Spring】Spring如何实现多数据源读写分离?这是我看过最详细的一篇!!
【程序人生】很多小伙伴说想看我的真容,这次满足你的好奇心!!
【MySQL】记一次线上重大事故:二狗子竟然把线上数据库删了!!
华为联运游戏或应用审核驳回:HMS Core升级提示语言类型错误
华为分析丨一文看懂安装归因,打造高转化的用户增长体系
热门文章
华为联运游戏或应用审核驳回:未调用检测更新接口(checkAppUpdate)
【接入指南】一个Demo带你玩转华为帐号服务
华为渠道自检包报错错误22:请集成华为HMS版本更新(checkUpdate)
如何兼顾隐私安全与便捷体验?华为浏览器集成FIDO,登录环境更安全
CloudDB对象类型创建失败,问题解决三板斧
【HarmonyOS挑战赛】150份定制礼品,20张现场门票,等你来!
colrm命令
col命令
命令模式
独一无二的出现次数
Copyright © 2011-2022 走看看