Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
ASP.NET 2.0 / 3.5 / 4.0
Generazione Thumb Foto
sabato 23 giugno 2012 - 08.17
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
Elenco Tags
VB.NET
|
.NET 4.0
gsistemi
Profilo
| Junior Member
100
messaggi | Data Invio:
sab 23 giu 2012 - 08:17
Ciao a tutti,
sto utilizzando il codice riportato qui sotto per generare la preview di alcune foto utilizzando .Net. Funziona tutto tranne che ho problemi con la qualità dell'immagine generata. Sul mio server locale configurato con IIS la preview generata è perfetta, antialias, qualità immagine, ecc... Quando eseguo la stessa funzione sul server remoto l'immagine esce sgranata e di scarsa qualità. L'unica differenza tra i due server è la versione di IIS 6.0 e 7.5 e il sistema operativo Win2003 server - Windows 7, su quello Windows 2003 server con IIS 6 funziona male.
E' normale o sbaglio qualcosa?
sub genera_thumb( path as string, foto as string, w as integer, h as integer )
try
if system.io.file.exists ( strFolder & "_thm\" & path & "\" & foto ) = true then
system.io.file.delete( strFolder & "_thm\" & path & "\" & foto )
end if
catch ex as exception
response.write("<p>Errore cancellazione thumb: " & path & "/" & foto & " - " & ex.message & "</p>")
end try
if ( w / h ) >= ( 83 / 95 ) then
w = cint( 95 * w / h )
h = 95
else
h = cint( h * 83 / w )
w = 83
end if
try
Encoders = myImageCodecInfo(1)
myEncoderParameters = New system.drawing.imaging.EncoderParameters(3)
myEncoderParameters.Param(0) = New system.drawing.imaging.EncoderParameter(system.drawing.imaging.Encoder.ColorDepth, CType(24L, Int32))
myEncoderParameters.Param(1) = New system.drawing.imaging.EncoderParameter(system.drawing.imaging.Encoder.Compression, 0)
myEncoderParameters.Param(2) = New system.drawing.imaging.EncoderParameter(system.drawing.imaging.Encoder.Quality, 80)
dim btm as new bitmap( img, w, h )
btm.setresolution( 72F, 72F )
dim thm as system.drawing.image = btm
dim grf as system.drawing.graphics
grf = system.drawing.graphics.fromimage(thm)
grf.compositingquality = system.drawing.drawing2d.compositingquality.highquality
grf.smoothingmode = system.drawing.drawing2d.smoothingmode.AntiAlias
grf.PixelOffsetMode = system.drawing.drawing2d.PixelOffsetMode.HighQuality
grf.interpolationmode = system.drawing.drawing2d.interpolationmode.HighQualityBilinear
grf.drawimage( thm, new rectangle( 0, 0, w, h ), w, h, w, h, graphicsunit.pixel )
btm = new bitmap( thm, 83, 95 )
btm.setresolution( 72F, 72F )
dim finale as system.drawing.image = btm
grf = system.drawing.graphics.fromimage(finale)
grf.drawimage( thm, new rectangle( 0, 0, 83, 95 ), cint( ( w - 83 ) / 2 ), cint( ( h - 95 ) / 2 ), 83, 95, graphicsunit.pixel )
finale.save( strfolder & "_thm/" & path & "/" & foto, Encoders, myEncoderParameters )
grf.dispose
btm.dispose
thm.dispose
finale.dispose
btm.dispose
catch ex as exception
response.write( "<p>Funzione Genera Thumb: " & path & "/" & foto & " - thumb: " & ex.message & "</p>" )
end try
end sub
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !