io non so più che dire
Questo è l'ultimo esempio
pagina
codice:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="a.aspx.vb" Inherits="a" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
[img]a.aspx?img=1[/img]
</div>
</form>
</body>
</html>
codice
codice:
Option Strict On
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Partial Class a
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim img As String = Me.Request.QueryString("img")
If img = "1" Then
getImg()
End If
End Sub
Private Sub getImg()
Dim file As String = "C:\dati\Prove Nicon\prova.jpg"
Dim bmp As Bitmap = DirectCast(Image.FromFile(file), Bitmap)
ImgBorda(bmp, 10, Color.Red)
Me.Response.Clear()
Me.Response.ContentType = "image/jpeg"
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bmp.Dispose()
Me.Response.End()
End Sub
Public Sub ImgBorda(ByRef bmp As Bitmap, ByVal bordoPixel As Integer, ByVal coloreSottofondo As Color)
Dim contenitoreW As Integer = bmp.Width + bordoPixel + bordoPixel
Dim contenitoreH As Integer = bmp.Height + bordoPixel + bordoPixel
Dim bmp1 As New Bitmap(contenitoreW, contenitoreH, bmp.PixelFormat)
bmp1.Tag = bmp.Tag
bmp1.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution)
Dim gr As Graphics = Graphics.FromImage(bmp1)
gr.Clear(coloreSottofondo)
'imposto lavoro alta qualità
gr.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
gr.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
gr.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
gr.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
gr.DrawImage(bmp, New Rectangle(CInt((contenitoreW - bmp.Width) / 2), CInt((contenitoreH - bmp.Height) / 2), bmp.Width, bmp.Height), New Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel)
bmp.Dispose()
gr.Dispose()
bmp = bmp1
End Sub
End Class