Visualizzazione dei risultati da 1 a 9 su 9

Discussione: Resize in asp.net

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    439

    Resize in asp.net

    Buongiorno avrei bisogno di un aiuto...

    Ho questo codice che funziona correttamente e serve a far visualizzare in dimensioni ridotte (non di kb) una immagine.

    codice:
     [img]image1.jpg[/img]
    Poi ho provato ad adattare questo script preso da fotopix per il resize in asp.net per il ridimensionamento "al volo" delle immagini. (Questo è lo script originale e funzionante):

    codice:
    <%
    	  response.write"[img]&strfile&[/img]"
    	  %>
    e queste sono le prove che ho fatto per provare ad adattarlo secondo le mie esigenze ma nessuna prova funziona:

    codice:
    [img]&image1.jpg&[/img]
    codice:
    [img]resize.aspx?w=128&h=128&src=image1.jpg[/img]
    codice:
    [img]image1.jpg[/img]
    codice:
    [img]resize.aspx?w=128&h=128&src=image1.jpg[/img]
    Quale prova mi manca che potrebbe essere quella giusta???

    Da premettere che ho inserito la mia pagina con il codice non funzionante, la pagina resize.aspx (che trovate di seguito) e l'immagine da visualizzare, nella root del sito.

    questa è la pagina resize.aspx

    codice:
    <%@ import namespace="System" %> 
    <%@ import namespace="System.Drawing" %> 
    <%@ import namespace="System.Drawing.Imaging" %> 
    <%@ import namespace="System.IO" %> 
    <script runat="server"> 
    Function NewthumbSize(currentwidth, currentheight) 
    ' Calculate the Size of the New image 
    dim k,a,b,c,d as Double
    k=currentwidth/currentheight
    a=currentwidth
    b=currentheight
    c=Request.QueryString("h")
    d=Request.QueryString("w")
    'if (k<=1 and currentheight>=c) then 
    'a=c*k
    'b=c
    'end if
    if (k>1) then 
    a=d
    b=d/k
    else
    a=c*k
    b=c
    end if
    dim NewSize as New Size(a, b)
    return NewSize 
    End Function 
    Sub sendFile() 
    ' create New image and bitmap objects. Load the image file and put into a resized bitmap. 
    dim g as System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath(request("src"))) 
    'dim g as System.Drawing.Image = System.Drawing.Image.FromFile(request("src")) 
    ' initialise the web object
    'Dim webC As New System.Net.WebClient()
    ' set the URL
    'Dim strFilename as string
    'if Request.QueryString("src")="" then
    '	strFilename="http://127.0.0.1/chiave.jpg"
    'else
    '	strFilename="http://127.0.0.1/thumbaspx/"&Request.QueryString("src")
    'end if
    ' create a bitmap based on the image from the URL 
    'Dim g = New System.Drawing.Bitmap(webC.OpenRead(strFilename))
    dim thisFormat=g.rawformat 
    dim thumbSize as New size 
    thumbSize=NewthumbSize(g.width,g.height) 
    dim imgOutput as New Bitmap(g, thumbSize.width, thumbSize.height) 
    ' Set the contenttype 
    'if thisformat.equals(system.drawing.imaging.imageformat.Gif) then 
    response.contenttype="image/gif" 
    else 
    response.contenttype="image/jpeg" 
    end if 
    ' send the resized image to the viewer 
    imgOutput.save(response.outputstream, thisformat) ' output to the user 
    ' tidy up 
    g.dispose() 
    imgOutput.dispose() 
    end sub 
    Sub sendError() 
    ' if no height, width, src then output "error" 
    dim imgOutput as New bitmap(120, 120, pixelformat.format24bpprgb) 
    dim g as graphics = graphics.fromimage(imgOutput)  
    'create a New graphic object from the above bmp 
    g.clear(color.yellow) ' blank the image 
    g.drawString("ERRORE!", New font("verdana",14,fontstyle.bold),systembrushes.windowtext,new pointF(2,2)) 
    ' Set the contenttype 
    response.contenttype="image/jpeg" 
    ' send the resized image to the viewer 
    imgOutput.save(response.outputstream, imageformat.jpeg) ' output to the user 
    ' tidy up 
    g.dispose() 
    imgOutput.dispose() 
    end sub 
    </script> 
    <% 
    ' make sure Nothing has gone to the client 
    response.clear 
    if request("src")="" then 
    call sendError() 
    else 
    if file.exists(server.mappath(request("src"))) then 
    call sendFile() 
    else 
    call sendError() 
    end if 
    end if 
    response.end 
    %>
    GRAZIE IN ANTICIPO

  2. #2
    mi sembra di capire che tu hai già sul server l'immagine "grande" e ti serve di farla vedere piccola quando richiedi una certa pagina.
    SOlitamente il resize lo si applica insieme all'upload, in questo modo hai già subito tutte e 2 le immagini.

    Nel tuo caso cercherei di capire bene come funziona il resize (senza scopiazzare paro paro ) e farei partire la funzione di resize sulla richiesta della pagina.
    Frate Priore: "È Lucifero in persona!"
    Trinità: "Lo conosci?"
    Bambino: "Mai sentito nominare, deve essere un professionista dell'est"

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    439
    Ciao!
    Già ho la pagina di upload e poi ho già la pagina di visualizzazione delle immagini inserite... in effetti il codice mio (non quello di prova) è il seguente:

    codice:
    [img]../public/foto/<%=(RS2.Fields.Item([/img]" border="5" height="100">
    mi potresti aiutare perfavore?

  4. #4
    <%=(RS2.Fields.Item("PosFoto").Value)%>

    ?? ma è asp o è asp.net ??

    mi sà tanto di asp ... e di dreamweaver in particolare
    Frate Priore: "È Lucifero in persona!"
    Trinità: "Lo conosci?"
    Bambino: "Mai sentito nominare, deve essere un professionista dell'est"

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    439
    è su una pagina .asp ...
    ma perchè il richiamo resize.aspx non è possibile implementarlo su una pagina .asp?

    PS Scusa l'ignoranza!!!

  6. #6
    purtroppo ci abbiamo sbatutto tutti la testa però se cerchi in rete trovi il materiale.

    compressione:
    http://www.aspitalia.com/liste/usag/script.aspx?ID=517

    per creare una thumb
    http://www.dotnethell.it/tips/tip.aspx?TipID=66

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    439
    ho dato un'occhiata ma non sono riuscito a capire come richiamare lo script per il mio sito!

  8. #8

  9. #9
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    439
    Grazie ski... provo subito

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.