用ASP.NET上传图片并生成可带版权信息的缩略图

阅读: 评论:0

用ASP.NET上传图片并生成可带版权信息的缩略图

用ASP.NET上传图片并生成可带版权信息的缩略图

function AddText(NewCode) {
tent.value+=NewCode
}

function email() {
if (helpstat) {
alert(“Email 标记n插入 Email 超级链接n用法1: [email]web@booro[/email]n用法2: [email=web@booro特鸟飞勤[/email]”);
} else if (basic) {
AddTxt="[email][/email]";
AddText(AddTxt);
} else {
txt2=prompt(“链接显示的文字.n如果为空,那么将只显示你的 Email 地址”,"");
if (txt2!=null) {
txt=prompt(“Email 地址.”,“stskyweb@21cn”);
if (txt!=null) {
if (txt2=="") {
AddTxt="[email]"+txt+"[/email]";
} else {
AddTxt="[email="+txt+"]"+txt2;
AddText(AddTxt);
AddTxt="[/email]";
}
AddText(AddTxt);
}
}
}
}
function flash() {
if (helpstat){
alert(“Flash 动画n插入 Flash 动画.n用法: [flash]Flash 文件的地址[/flash]”);
} else if (basic) {
AddTxt="[flash][/flash]";
AddText(AddTxt);
} else {
txt=prompt(“Flash 文件的地址”,“”);
if (txt!=null) {
AddTxt="[flash]"+txt;
AddText(AddTxt);
AddTxt="[/flash]";
AddText(AddTxt);
}
}
}

function showsize(size) {
if (helpstat) {
alert(“文字大小标记n设置文字大小.n可变范围 1 - 6.n 1 为最小 6 为最大.n用法: [size=”+size+"]这是 “+size+” 文字[/size]");
} else if (basic) {
AddTxt="[size="+size+"][/size]";
AddText(AddTxt);
} else {
txt=prompt(“大小 “+size,“文字”);
if (txt!=null) {
AddTxt=”[size=”+size+"]"+txt;
AddText(AddTxt);
AddTxt="[/size]";
AddText(AddTxt);
}
}
}

function bold() {
if (helpstat) {
alert(“加粗标记n使文本加粗.n用法: [b]这是加粗的文字[/b]”);
} else if (basic) {
AddTxt="[b][/b]";
AddText(AddTxt);
} else {
txt=prompt(“文字将被变粗.”,“文字”);
if (txt!=null) {
AddTxt="[b]"+txt;
AddText(AddTxt);
AddTxt="[/b]";
AddText(AddTxt);
}
}
}

function italicize() {
if (helpstat) {
alert(“斜体标记n使文本字体变为斜体.n用法: [i]这是斜体字[/i]”);
} else if (basic) {
AddTxt="[i][/i]";
AddText(AddTxt);
} else {
txt=prompt(“文字将变斜体”,“文字”);
if (txt!=null) {
AddTxt="[i]"+txt;
AddText(AddTxt);
AddTxt="[/i]";
AddText(AddTxt);
}
}
}

function quote() {
if (helpstat){
alert(“引用标记n引用一些文字.n用法: [quote]引用内容[/quote]”);
} else if (basic) {
AddTxt="[quote][/quote]";
AddText(AddTxt);
} else {
txt=prompt(“被引用的文字”,“文字”);
if(txt!=null) {
AddTxt="[quote]"+txt;
AddText(AddTxt);
AddTxt="[/quote]";
AddText(AddTxt);
}
}
}

function showcolor(color) {
if (helpstat) {
alert(“颜色标记n设置文本颜色. 任何颜色名都可以被使用.n用法: [color=”+color+"]颜色要改变为"+color+“的文字[/color]”);
} else if (basic) {
AddTxt="[color="+color+"][/color]";
AddText(AddTxt);
} else {
txt=prompt(“选择的颜色是: “+color,“文字”);
if(txt!=null) {
AddTxt=”[color=”+color+"]"+txt;
AddText(AddTxt);
AddTxt="[/color]";
AddText(AddTxt);
}
}
}

function center() {
if (helpstat) {
alert(“对齐标记n使用这个标记, 可以使文本左对齐、居中、右对齐.n用法: [align=center|left|right]要对齐的文本[/align]”);
} else if (basic) {
AddTxt="[align=center|left|right][/align]";
AddText(AddTxt);
} else {
txt2=prompt(“对齐样式n输入 ‘center’ 表示居中, ‘left’ 表示左对齐, ‘right’ 表示右对齐.”,“center”);
while ((txt2!="") && (txt2!=“center”) && (txt2!=“left”) && (txt2!=“right”) && (txt2!=null)) {
txt2=prompt(“错误!n类型只能输入 ‘center’ 、 ‘left’ 或者 ‘right’.”,"");
}
txt=prompt(“要对齐的文本”,“文本”);
if (txt!=null) {
AddTxt="r[align="+txt2+"]"+txt;
AddText(AddTxt);
AddTxt="[/align]";
AddText(AddTxt);
}
}
}

function hyperlink() {
if (helpstat) {
alert(“超级链接标记n插入一个超级链接标记n使用方法: [url][/url]nUSE: [url=]链接文字[/url]”);
} else if (basic) {
AddTxt="[url][/url]";
AddText(AddTxt);
} else {
txt2=prompt(“链接文本显示.n如果不想使用, 可以为空, 将只显示超级链接地址. “,””);
if (txt2!=null) {
txt=prompt(“超级链接.”,“”);
if (txt!=null) {
if (txt2=="") {
AddTxt="[url]"+txt;
AddText(AddTxt);
AddTxt="[/url]";
AddText(AddTxt);
} else {
AddTxt="[url="+txt+"]"+txt2;
AddText(AddTxt);
AddTxt="[/url]";
AddText(AddTxt);
}
}
}
}
}

function image() {
if (helpstat){
alert(“图片标记n插入图片n用法: [img].gif[/img]”);
} else if (basic) {
AddTxt="[img][/img]";
AddText(AddTxt);
} else {
txt=prompt(“图片的 URL”,“”);
if(txt!=null) {
AddTxt="r[img]"+txt;
AddText(AddTxt);
AddTxt="[/img]";
AddText(AddTxt);
}
}
}

function showcode() {
if (helpstat) {
alert(“代码标记n使用代码标记,可以使你的程序代码里面的 html 等标志不会被破坏.n使用方法:n [code]这里是代码文字[/code]”);
} else if (basic) {
AddTxt="r[code]r[/code]";
AddText(AddTxt);
} else {
txt=prompt(“输入代码”,"");
if (txt!=null) {
AddTxt="r[code]"+txt;
AddText(AddTxt);
AddTxt="[/code]";
AddText(AddTxt);
}
}
}

function list() {
if (helpstat) {
alert(“列表标记n建造一个文字或则数字列表.nnUSE: [list] []项目一[/] []项目二[/] []项目三[/] [/list]”);
} else if (basic) {
AddTxt=" [list][] [/][] [/][] [/][/list]";
AddText(AddTxt);
} else {
txt=prompt(“列表类型n输入 ‘A’ 表示有序列表, ‘1’ 表示无序列表, 留空表示无序列表.”,"");
while ((txt!="") && (txt!=“A”) && (txt!=“a”) && (txt!=“1”) && (txt!=null)) {
txt=prompt(“错误!n类型只能输入 ‘A’ 、 ‘1’ 或者留空.”,"");
}
if (txt!=null) {
if (txt=="") {
AddTxt="[list]";
} else {
AddTxt="[list="+txt+"]";
}
txt=“1”;
while ((txt!="") && (txt!=null)) {
txt=prompt(“列表项n空白表示结束列表”,"");
if (txt!="") {
AddTxt+="[]"+txt+"[/]";
}
}
AddTxt+="[/list] ";
AddText(AddTxt);
}
}
}

function showfont(font) {
if (helpstat){
alert(“字体标记n给文字设置字体.n用法: [face=”+font+"]改变文字字体为"+font+"[/face]");
} else if (basic) {
AddTxt="[face="+font+"][/face]";
AddText(AddTxt);
} else {
txt=prompt(“要设置字体的文字”+font,“文字”);
if (txt!=null) {
AddTxt="[face="+font+"]"+txt;
AddText(AddTxt);
AddTxt="[/face]";
AddText(AddTxt);
}
}
}
function underline() {
if (helpstat) {
alert(“下划线标记n给文字加下划线.n用法: [u]要加下划线的文字[/u]”);
} else if (basic) {
AddTxt="[u][/u]";
AddText(AddTxt);
} else {
txt=prompt(“下划线文字.”,“文字”);
if (txt!=null) {
AddTxt="[u]"+txt;
AddText(AddTxt);
AddTxt="[/u]";
AddText(AddTxt);
}
}
}
function setfly() {
if (helpstat){
alert(“飞翔标记n使文字飞行.n用法: [fly]文字为这样文字[/fly]”);
} else if (basic) {
AddTxt="[fly][/fly]";
AddText(AddTxt);
} else {
txt=prompt(“飞翔文字”,“文字”);
if (txt!=null) {
AddTxt="[fly]"+txt;
AddText(AddTxt);
AddTxt="[/fly]";
AddText(AddTxt);
}
}
}

function move() {
if (helpstat) {
alert(“移动标记n使文字产生移动效果.n用法: [move]要产生移动效果的文字[/move]”);
} else if (basic) {
AddTxt="[move][/move]";
AddText(AddTxt);
} else {
txt=prompt(“要产生移动效果的文字”,“文字”);
if (txt!=null) {
AddTxt="[move]"+txt;
AddText(AddTxt);
AddTxt="[/move]";
AddText(AddTxt);
}
}
}

function shadow() {
if (helpstat) {
alert(“阴影标记n使文字产生阴影效果.n用法: [SHADOW=宽度, 颜色, 边界]要产生阴影效果的文字[/SHADOW]”);
} else if (basic) {
AddTxt="[SHADOW=255,blue,1][/SHADOW]";
AddText(AddTxt);
} else {
txt2=prompt(“文字的长度、颜色和边界大小”,“255,blue,1”);
if (txt2!=null) {
txt=prompt(“要产生阴影效果的文字”,“文字”);
if (txt!=null) {
if (txt2=="") {
AddTxt="[SHADOW=255, blue, 1]"+txt;
AddText(AddTxt);
AddTxt="[/SHADOW]";
AddText(AddTxt);
} else {
AddTxt="[SHADOW="+txt2+"]"+txt;
AddText(AddTxt);
AddTxt="[/SHADOW]";
AddText(AddTxt);
}
}
}
}
}

function glow() {
if (helpstat) {
alert(“光晕标记n使文字产生光晕效果.n用法: [GLOW=宽度, 颜色, 边界]要产生光晕效果的文字[/GLOW]”);
} else if (basic) {
AddTxt="[glow=255,red,2][/glow]";
AddText(AddTxt);
} else {
txt2=prompt(“文字的长度、颜色和边界大小”,“255,red,2”);
if (txt2!=null) {
txt=prompt(“要产生光晕效果的文字.”,“文字”);
if (txt!=null) {
if (txt2=="") {
AddTxt="[glow=255,red,2]"+txt;
AddText(AddTxt);
AddTxt="[/glow]";
AddText(AddTxt);
} else {
AddTxt="[glow="+txt2+"]"+txt;
AddText(AddTxt);
AddTxt="[/glow]";
AddText(AddTxt);
}
}
}
}
}
function openscriphtml()
{
if (navigator.appName!=“Microsoft Internet Explorer”)
alert(“此功能 Netscape 用户不能使用!”)
else
{newwin=window.open(‘htmledit/editor.html’,’’,‘width=544,height=294’);
newwin.focus();
}
}
function runEx(){
//alert(‘请注意,按下确定将生成页面,按下后请稍后…’);
var winEx = window.open("", “winEx”, “width=600,height=400,status=yes,menubar=yes,scrollbars=yes,resizable=yes”); winEx.document.open(“text/html”, “replace”);
winEx.document.write(unescape(event.srcElement.parentElement.children[2].value));
winEx.document.close();
}
function openScript(url, width, height) {
var Win = window.open(url,“openScript”,‘width=’ + width + ‘,height=’ + height + ‘,resizable=1,scrollbars=yes,menubar=yes,status=yes’ );
}

      用ASP.NET上传图片并生成可带版权信息的缩略图  
            你是第187位浏览该文章的人xiahouwenc   csdn   2003-9-30
<%@ Page Language="C#" ResponseEncoding="gb2312" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<script runat="server">

void Page_Load(Object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
ImgPreview.Visible=false;
}
}
void GetThumbnailImage(int width,int height,string strInfo,int left,int right)
{
string file="Uploads/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\')+1);
string newfile="Uploads/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\')+1)+".jpg";
string strAdd=strInfo;
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(Server.MapPath(file));
System.Drawing.Image thumbnailImage =
oldimage.GetThumbnailImage(width, height,new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
Response.Clear();
Bitmap output=new Bitmap(thumbnailImage);
Graphics g=Graphics.FromImage(output);
g.DrawString(strAdd,new Font("Courier New", 14),new SolidBrush(Color.Red),left,right);
output.Save(Server.MapPath(newfile),System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ContentType = "image/gif";
ImgPreview.Visible=true;
ImgPreview.ImageUrl=newfile;
}
bool ThumbnailCallback()
{
return true;
}

void Button_Click(object sender, EventArgs e)
{
int width,height,left,right;
string strAddInfo=txtAddInfo.Text;
width=Int32.Parse(txtWidth.Text);
height=Int32.Parse(txtHeight.Text);
left=Int32.Parse(txtLeft.Text);
right=Int32.Parse(txtRight.Text);
if(!(uploadFile.PostedFile.ContentLength>0))
{
lblErrInfo.Text="没有选择文件";
}
else
{

string path = Server.MapPath("./Uploads/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\')+1));
if(File.Exists(path))
{
lblErrInfo.Text="已经有同名文件";
}
else
{
uploadFile.PostedFile.SaveAs(path);
GetThumbnailImage(width,height,strAddInfo,left,right);
}
}
}
</script>
<html>
<head>
</head>
<body>
<form method="post" enctype="multipart/form-data" runat="server">
<p>
<input id="uploadFile" type="file" runat="server" />
<asp:Label id="lblErrInfo" runat="server" forecolor="Red"></asp:Label>
</p>
<p>
width:<asp:TextBox id="txtWidth" runat="server" Width="40px">100</asp:TextBox>
 height:<asp:TextBox id="txtHeight" runat="server" Width="40px">150</asp:TextBox>
 
</p>
<p>
添加信息:<asp:TextBox id="txtAddInfo" runat="server"> AspxBoy.Com</asp:TextBox>
</p>
<p>
信息位置:left:<asp:TextBox id="txtLeft" runat="server" Width="40px">10</asp:TextBox>
 right:<asp:TextBox id="txtRight" runat="server" Width="40px">135</asp:TextBox>
</p>
<p>
 
<input id="button" type="button" value="上传生成所略图" onServerClick="Button_Click" runat="server" />
</p>
<p><asp:Image id="ImgPreview" runat="server"></asp:Image>
</p>
<!-- Insert content here -->
</form>
</body>
</html>



  上篇文章:ASP.NET的层次数据显示技术
  下篇文章:在.NET中创建弹出窗口的方法

      

本文发布于:2024-01-29 04:38:01,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170647428412751.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:上传图片   缩略图   版权   信息   ASP
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23