<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<%@ Page Language="vb" AutoEventWireup="false" %>
<html>
<body>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'prendo i dati dalla pagina
Dim fileOriginale As String = Convert.ToString(Request.QueryString("File"))
Dim Stringa As String = Convert.ToString(Request.QueryString("Stringa"))
Dim myFontColorTemp As String = Convert.ToString(Request.QueryString("Color"))
Dim myFontName As String = Convert.ToString(Request.QueryString("Font"))
Dim myX As Single = Convert.ToSingle(Request.QueryString("X"))
Dim myY As Single = Convert.ToSingle(Request.QueryString("Y"))
Dim myFontDim As Single = Convert.ToSingle(Request.QueryString("Dim"))
'setto le mancanze
If fileOriginale = String.Empty Then fileOriginale = "Vuoto.jpg"
If Stringa = String.Empty Then Stringa = "[Errore nel caricamento.]" & vbNewLine & vbNewLine & vbNewLine & _
"Es: page.aspx?File=imm.jpg&Stringa=Ciao" & vbNewLine & vbNewLine & _
"Parametri:" & vbNewLine & vbNewLine & _
" - 'file' = immagine su cui scrivere" & vbNewLine & _
" - 'stringa' = testo da scrivere" & vbNewLine & _
" - 'font' = font carattere" & vbNewLine & _
" - 'color' = colore scritta" & vbNewLine & _
" - 'dim' = dimensione scritta" & vbNewLine & _
" - 'x' = posizione x" & vbNewLine & _
" - 'y' = posizione y"
If myX < 0 Then myX = 10
If myY < 0 Then myY = 10
If myFontDim < 6 Then myFontDim = 14
If myFontColorTemp = String.Empty Then myFontColorTemp = "Black"
Dim myFontColor As System.Drawing.Color = System.Drawing.Color.FromName(myFontColorTemp)
If myFontName = String.Empty Then myFontName = "FixedSys"
'istanzio le var
Dim myImage As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("\public\GalleryFile\" & fileOriginale))
Dim myGraphics As Graphics = Graphics.FromImage(myImage)
Dim DrawFont As New Font(myFontName, myFontDim, FontStyle.Bold)
Dim DrawBrush As New SolidBrush(myFontColor)
myGraphics.DrawString(Stringa, DrawFont, DrawBrush, myX, myY)
'rispondo il file modificato
Response.ContentType = "image/jpeg"
myImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
myImage.Dispose()
myGraphics.Dispose()
End Sub
</script>
</body>
</html>