Ver Mensaje Individual
  #3 (permalink)  
Antiguo 22/05/2006, 08:29
Avatar de lexus
lexus
 
Fecha de Ingreso: enero-2002
Ubicación: Cali - Colombia
Mensajes: 2.234
Antigüedad: 23 años, 2 meses
Puntos: 4
mira este tambien es muy bueno


watermark.aspx
Cita:
<%@ Page Explicit="True" Language="VB" Debug="True" %>
<%@ Import Namespace="system.drawing" %>
<%@ Import Namespace="system.drawing.imaging" %>
<%@ Import Namespace="system.drawing.drawing2d" %>
<%@ Import Namespace="system.io" %>
<script runat="server">

dim Filename as String
dim Width, Height, shadowSize as Integer
dim Bitmap as system.drawing.bitmap
dim ImgFormat as ImageFormat
dim Img as System.Drawing.Image
Dim baseMap as Bitmap
dim top, left as Integer
sub CreateGraphic()
Dim letterBrush as SolidBrush = new SolidBrush(Color.FromArgb(50, 255, 255, 255))
Dim shadowBrush as SolidBrush = new SolidBrush(Color.FromArgb(50, 0, 0, 0))
Dim fontTitle as Font = new Font("tahoma", 20, FontStyle.Bold)
Filename = Request.QueryString("filename")
Filename = server.mappath(Filename)
ImgFormat = ImageFormat.jpeg : response.contenttype="image/jpeg" ' Default=jpeg '
Img = system.drawing.image.FromFile(Filename)
Width = Img.Width
Height = Img.Height
baseMap = new Bitmap(Width,Height)
Dim myGraphic as Graphics = Graphics.FromImage(baseMap)
with myGraphic
.DrawImage(Img, 0,0, Width,Height)
.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
.DrawString("LABS.INSERT-TITLE.COM", fontTitle, shadowBrush, 5, 60)
.DrawString("LABS.INSERT-TITLE.COM", fontTitle, letterBrush, 7, 62)
end with
Img.dispose()
end sub
</script>
<%
CreateGraphic
baseMap.Save(Response.OutputStream, ImageFormat.JPEG)
baseMap.dispose()
Img = Nothing
response.end
%>
<br />If you enjoyed this post <a href="<A href="http://del.icio.us/login?url=http%3A%2F%2Fwww.labs.inserttitle.com%2F labs%2FQuick-Watermark_article832.aspx;title=Quick+Watermark;v= 2">Bookmark">http://del.icio.us/login?url=http%3A%2F%2Fwww.labs.inserttitle.com%2F labs%2FQuick-Watermark_article832.aspx;title=Quick+Watermark;v= 2">Bookmark it at del.icio.us</a><br />
<div id="comm_space">
<hr />
<h3>Comments</h3>

<div class="comment">
<span class="comment_name">Chris Mc</span>
<span class="commentdate">2/21/2005 3:39:12 AM</span>
Fantastic script, just what i was after! </div>

<div class="comment">
<span class="comment_name">Gabe Taylor</span>
<span class="commentdate">5/27/2005 1:33:48 PM</span>
Why do I get the following error? Am I missing some ASP component?
<br /><br />
Thanks.
<br /><br />
-------------
<br /><br />
Active Server Pages error `ASP 0221`
<br /><br />
Invalid @ Command directive
<br /><br />
/onlocation/test.asp, line 1
<br /><br />
The specified `Page Explicit="True" Language="VB" Debug="True" ` option is unknown or invalid.
<br /><br />
------------- </div>

<div class="comment">
<span class="comment_name"><a href="<A href="http://www.cascadecomputing.com">gabe/">http://www.cascadecomputing.com">Gabe Taylor</a><br /></span>
<span class="commentdate">5/27/2005 1:34:32 PM</span>
Please email reply to [email protected] </div>

<div class="comment">
<span class="comment_name"><a href="<A href="http://www.insert-title.com">joe/">http://www.insert-title.com">Joe Maddalone</a><br /></span>
<span class="commentdate">5/27/2005 1:55:50 PM</span>
Save the first chunk of code as "watermark.aspx"
<br /><br />
Then in your ASP page make the src of the image:
<br /><br />
<img src="watermark.aspx?filename=FILENAME.JPG" />
</div>

<div class="comment">
<span class="comment_name">Gabe Taylor</span>
<span class="commentdate">5/27/2005 7:44:48 PM</span>
Hmm... I receive the following:
<br /><br />
Microsoft VBScript runtime error `800a01a8`
<br /><br />
Object required: ``
<br /><br />
/onlocation/images.html, line 4
<br /><br />
Line 4 being the one that has
<img src="watermark.aspx?filename=FILENAME.JPG" />
<br /><br />
Is there a component that I need for this to work that would not be part of ASP 3.0?
<br /><br />
Thanks. </div>

<div class="comment">
<span class="comment_name">Joe Maddalone</span>
<span class="commentdate">8/13/2005 10:57:38 AM</span>
This is ASP.NET you need at least the .Net Framework 1.0 or 1.1, which you can download for free form Microsoft. Just check Google for ".Net Framework download".
<br /><br />
FILENAME.JPG... replace that with the actualy filename of an actual image, on your actual server. </div>

<div class="comment">
<span class="comment_name">Antonio</span>
<span class="commentdate">11/12/2005 1:49:51 AM</span>
Great Code, And Thanks for share it.
I got some questions:
Why this piece of code is used twice?
<%
CreateGraphic
baseMap.Save(Response.OutputStream, ImageFormat.JPEG)
baseMap.dispose()
Img = Nothing
response.end
%>
<br /><br />
And A further question?
After Run it the process aspnet_wp.exe Start.
Even If I move to another page the process is running.
How Stop this proccess?
<br /><br />
Thanks in advance
</div>

<div class="comment">
<span class="comment_name">Joe Maddalone</span>
<span class="commentdate">11/14/2005 7:24:26 AM</span>
THe doubling up on the <% CreateGraphic baseMap... line is a typo - I`ll fix that today.
<br /><br />
Your other question is something I will look into for you. </div>

<hr />
<div class="google-inarticle" ID="inarticle">
0110 1001 1001 0110
</div>


<form name="comments_form" method="post" action="default.aspx?id=832" id="comments_form">
<input type="hidden" name="__VIEWSTATE" value="dDwtMTIzMTAwOTc3OTs7Ppi31DQd+zxtdd8TWDrrPB2 ih4j1" />
<h3>Leave a Comment</h3>
<label for="name">Name:</label>

<input name="name" type="text" id="name" />

<label for="url">URL:</label>

<input name="url" type="text" id="url" />
<br />
<br />
<label for="SubmitComments">Comments:</label>
<br />
<textarea name="SubmitComments" rows="10" cols="40" id="SubmitComments">
__________________
Control de Visitantes, Control de Accesos, Minutas digitales, Manejo de Correspondencia
http://www.controldevisitantes.com