Ciao a tutti, sto utilizzando un codice freeasp per un resize,
ora però mi sono incartato con il richiamo dell'immagine che è dinamcica
prima
dopocodice:[img]<%= oRst([/img]" align="left">
codice:[img]resize.aspx?Filename=<%= oRst([/img]&ScaleFactor=20" align="left">
il file resize.aspx è
esattamente uguale a quicodice:<%@ Page Language="C#" %> <%@ import Namespace="System.Drawing" %> <%@ import Namespace="System.Drawing.Imaging" %> <%@ import Namespace="System.Text.RegularExpressions" %> <script runat="server"> int MaxWidth = 100; // Larghezza massima dopo il quale l'immagine viene ridimensionata int MaxHeight = 100; // Altezza massima dopo il quale l'immagine viene ridimensionata int ScaleFactor = 20; // Fattore di scala per la miniatura System.Drawing.Image oldImage, newImage; void Page_Load(Object sender, EventArgs e) { if ( Request.QueryString["FileName"'> != null ) { string strFileName = Convert.ToString(Request.QueryString["FileName"'>); if ( Request.QueryString["ScaleFactor"'> != null && Convert.ToString(Request.QueryString["ScaleFactor"'>) != "" && IsInteger(Convert.ToString(Request.QueryString["scalefactor"'>)) ) ScaleFactor = Convert.ToInt32(Request.QueryString["ScaleFactor"'>); if ( strFileName != "" ) { try { oldImage = System.Drawing.Image.FromFile( Server.MapPath(strFileName) ); if ( oldImage.Width > MaxWidth || oldImage.Height > MaxHeight ) { // Immagine troppo grande, visualizzo la miniatura newImage = oldImage.GetThumbnailImage( (oldImage.WidthScaleFactor/100), (oldImage.HeightScaleFactor/100), null, IntPtr.Zero); Response.ContentType = "image/jpeg"; newImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); oldImage.Dispose(); newImage.Dispose(); oldImage = null; newImage = null; } else { // Immagine piccola, non faccio nulla Response.ContentType = "image/jpeg"; oldImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); oldImage.Dispose(); oldImage = null; } } catch (Exception ex) { Response.Write(ex.Message); } } } } private bool IsInteger(string strTmp) { Regex objNotIntPattern = new Regex("[^0-9-'>"); Regex objIntPattern = new Regex("^-[0-9'>+$|^[0-9'>+$"); return !objNotIntPattern.IsMatch(strTmp) && objIntPattern.IsMatch(strTmp); } </script>
Help, grazie 1000!

Rispondi quotando