Johan Knape Posted September 27, 2004 Share Posted September 27, 2004 Hej, Jag använder följande kod. Public Sub ResizeAndSaveImage(ByVal ImagePath As String, _ ByVal NewWidth As Integer, _ ByVal NewHeight As Integer, _ ByVal DestinationPath As String) 'Load the source bitmap Dim bm_source As New Bitmap(ImagePath) 'Create the destination bitmap Dim bm_dest As New Bitmap(NewWidth, NewHeight) 'Create a graphics object Dim gr_dest As Graphics = Graphics.FromImage(bm_dest) [color="#ff0000"]gr_dest.InterpolationMode = InterpolationMode.HighQualityBicubic[/color] 'Re-draw the image to the specified height and width 'gr_dest.FillRectangle( Brushes.White,0,0,bm_dest.Width, bm_dest.Height) gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width , bm_dest.Height ) 'Save the resulting image bm_dest.Save(DestinationPath,ImageFormat.Jpeg) 'Release objects bm_source.Dispose() bm_source = Nothing bm_source = Nothing bm_dest = Nothing gr_dest = Nothing End Sub Får följande fel meddelande: Kompilatorfel Beskrivning: Ett fel inträffade vid kompilering av en resurs som är nödvändig för att utföra den aktuella begäran. Granska den specifika felinformationen nedan och gör nödvändiga ändringar i källkoden. Kompilatorfelmeddelande: BC30469: En referens till en icke-delad medlem kräver en objektreferens. Källfel: Rad 96: 'Create a graphics object Rad 97: Dim gr_dest As Graphics = Graphics.FromImage(bm_dest) Rad 98: gr_dest.InterpolationMode = Graphics.InterpolationMode.HighQualityBicubic Rad 99: Rad 100: 'Re-draw the image to the specified height and width Källfil: c:\inetpub\wwwroot\tallrikar\upload.aspx Rad: 98 gr_dest.InterpolationMode = Graphics.InterpolationMode.HighQualityBicubic ~~~~~~~~~~~~~~~~~~~~~~~~~~ Har följande imports -> <%@ Page Language="VB" ContentType="text/html" strict = "false"%> <%@ import namespace="System" %> <%@ import namespace="System.Drawing" %> <%@ import namespace="System.Drawing.Imaging" %> <%@ import namespace="System.IO" %> All hjälp uppskattas /Johan Link to comment Share on other sites More sharing options...
Anjuna Moon Posted September 27, 2004 Share Posted September 27, 2004 Pröva att importera även Imports System.Drawing.Drawing2D Link to comment Share on other sites More sharing options...
Johan Knape Posted September 27, 2004 Author Share Posted September 27, 2004 Självklart var det så enkelt. Lite frustrerande att problemen skall vara så svåra och lösningarna så enkla *s*. Nåja man tackar ödmjukast. Naturligtvis poäng. /Johan Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.