Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Resize Immagini

  1. #1

    Resize Immagini

    ho notato che utilizzando la funzione ReDimImg non rispetta la risoluzione ... come si può risolvere?

    immagine originale


    immagine ridotta con la funzione ReDimImg


    immagine ridotta con un programma di grafica

  2. #2
    allego la funzione ReDimImg
    codice:
         Public Sub ReDimImg(SourcePath as String,ResizeName as string, width as integer,height as integer) 
              Try
                   'Creo l'oggetto di riferimento al file originale
                   Dim TmpBmp as System.Drawing.Bitmap     = CType(System.Drawing.Image.FromFile(Server.MapPath(SourcePath)), System.Drawing.Bitmap) 
                   Dim newWidth,newHeight as string
                   'Se il parametro height è lasciato a 0 costruisco il with in maniera proporzionata
                   if height = 0 Then 
                        newHeight                = Convert.ToInt32(width / TmpBmp.Width * TmpBmp.Height)
                   else 
                        newHeight                = height
                   End if 
                   'Se il parametro with è lasciato a 0 costruisco l'height in maniera proporzionata
                   if width = 0 Then 
                        newWidth                = Convert.ToInt32(height / TmpBmp.Height * TmpBmp.Width) 
                   else
                        newWidth                = width
                   end if 
                   
                   'Creo la miniatura con lunghezza e larghezza elaborati 
                   Dim miniaturabmp as      New System.Drawing.Bitmap(TmpBmp, newWidth, newHeight)
                   'Distruggo l'oggetto dell'immagine originale che non mi serve +
                   TmpBmp.Dispose() 
                   
                   'controllo l'estensione e salvo la miniatura nel giusto formato 
                   if SourcePath.toLower().EndsWith(".jpg") or SourcePath.toLower().EndsWith(".jpeg") Then 
                        miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.Jpeg) 
                   elseif SourcePath.toLower().EndsWith(".gif") Then 
                        miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.Gif) 
                   elseif SourcePath.toLower().EndsWith(".png") Then 
                        miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.Png) 
                   else
                        Response.Write("Errore Formato")
                        'Si puo' ampliare l'elseif in questo modo:
                        'elseif SourcePath.toLower().EndsWith(".[Estensione]") Then 
                        'miniaturabmp.Save(Server.MapPath(ResizeName), System.Drawing.Imaging.ImageFormat.[Estensione]) 
                        'dove [Estensione] puo essere Bmp, Emf, Exif, Tiff, Wmf
                   end if 
                   miniaturabmp.Dispose() 
                   Catch ex as System.Exception 
                        'Nel caso stampo l'errore:
                        Response.Write("<hr>Errore nel ridimensionamento dell'immagine:
    " & ex.Message & "
    
    ")
                        Response.Write("
    " & ex.StackTrace & "<hr>") 
              End Try
              Response.Write("Ridimensionamento effettuato con successo")
         End Sub

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    1,786
    ho lo stesso problema, come posso risolvere ?

    grazie 10000000000 !
    [Scambio Links a Tema] Contattatemi in Privato x + Info.

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.