This function creates the Thumbnail image and returns the
image created in Byte() format
Private Function createThumnail()Function createThumnail(ByVal ImageStream As Stream,
ByVal tWidth As Double, ByVal tHeight As Double) As Byte()
  Dim g As System.Drawing.Image =System.Drawing.Image.FromStream(ImageStream)
  Dim thumbSize As New Size()
  thumbSize =NewthumbSize(g.Width, g.Height, tWidth, tHeight)
  Dim imgOutput As New Bitmap(g, thumbSize.Width, thumbSize.Height)
  Dim imgStream As New MemoryStream()
  Dim thisFormat = g.RawFormat
  imgOutput.Save(imgStream, thisFormat)
  Dim imgbin(imgStream.Length) As Byte
  imgStream.Position = 0
  Dim n As Int32 = imgStream.Read(imgbin, 0, imgbin.Length)
  g.Dispose()
  imgOutput.Dispose()
  Return imgbin
End FunctionFunction NewthumbSize()Function NewthumbSize(ByVal currentwidth As Double, ByVal
currentheight As Double, ByVal newWidth As Double, ByVal newHeight As Double)
  ' Calculate the Size of the New image 
  Dim tempMultiplier As Double  If currentheight > currentwidth Then ' portrait 
   tempMultiplier = newHeight / currentheight
  Else
   tempMultiplier = newWidth / currentwidth
  End If  Dim NewSize As New Size(CInt(currentwidth * tempMultiplier),
CInt(currentheight * tempMultiplier)) 
  Return NewSize
End Function

解决方案 »

  1.   

    你能不能帮忙该一下呀
    源码在http://www.cnblogs.com/rippleyong/archive/2004/08/10/31977.aspx
    我只要改变图片的大小的一些函数
      

  2.   

    VB.net -> C# 工具http://www.developerfusion.com/utilities/convertvbtocsharp.aspx
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=45E7E33C-F149-450E-B5D5-832958C20538在ASP.NET里轻松实现缩略图vb.net c#版http://dotnet.aspx.cc/Exam/Thumbnail.aspx
      

  4.   

    private byte[] createThumnail(Stream ImageStream, double tWidth, double tHeight) 

     System.Drawing.Image g = System.Drawing.Image.FromStream(ImageStream); 
     Size thumbSize = new Size(); 
     thumbSize = NewthumbSize(g.Width, g.Height, tWidth, tHeight); 
     Bitmap imgOutput = new Bitmap(g, thumbSize.Width, thumbSize.Height); 
     MemoryStream imgStream = new MemoryStream(); 
     object thisFormat = g.RawFormat; 
     imgOutput.Save(imgStream, thisFormat); 
     byte[imgStream.Length] imgbin; 
     imgStream.Position = 0; 
     Int32 n = imgStream.Read(imgbin, 0, imgbin.Length); 
     g.Dispose(); 
     imgOutput.Dispose(); 
     return imgbin; 
    } object NewthumbSize(double currentwidth, double currentheight, double newWidth, double newHeight) 

     double tempMultiplier; 
     if (currentheight > currentwidth) { 
       tempMultiplier = newHeight / currentheight; 
     } else { 
       tempMultiplier = newWidth / currentwidth; 
     } 
     Size NewSize = new Size(System.Convert.ToInt32(currentwidth * tempMultiplier), System.Convert.ToInt32(currentheight * tempMultiplier)); 
     return NewSize; 
    }
      

  5.   

    这样试一下。只保证在C#的转换正确。不保证你的函数是否正确。
    private byte[] createThumnail(Stream ImageStream,Double tWidth,Double tHeight)
    {
      System.Drawing.Image g = System.Drawing.Image.FromStream(ImageStream);
      System.Drawing.Size thumbSize = new Size(g.Width, g.Height, tWidth, tHeight);
      System.Drawing.Bitmap imgOutput = new Bitmap(g,thumSize.Width,thumSize.Height);
      System.IO.MemoryStream imgStream = new MemoryStream();
      System.Drawing.Imaging.ImageFormat thisFormat = g.RawFormat;
      imgOutput.Save(imgStream, thisFormat);
      byte[] imgbin = new byte[imgStream.Length];
      imgStream.Position = 0;
      int n = imgStream.Read(imgbin,0,imgbin.Length);
      g.Dispose();
      imgOutput.Dispose();
      return imgbin;  
    }public int NewthumbSize(Double currentwidth,Double currentheight,Double newWidth, Double newHeight)
    {
      Double tempMultiplier;
      if(currentheight > currentwidth)
         tempMultiplier = newHeight / currentheight;
      else
         tempMultiplier = newWidth / currentwidth;
      System.Drawing.Size NewSize = new Size(Convert.ToInt32(currentwidth * tempMultiplier),Convert.ToInt32(currentheight * tempMultiplier));
       return NewSize;
    }
      

  6.   

    工具转的
    private byte[] createThumnail(Stream ImageStream,Double tWidth,Double tHeight)
    {
      System.Drawing.Image g = System.Drawing.Image.FromStream(ImageStream);
      System.Drawing.Size thumbSize = new Size(g.Width, g.Height, tWidth, tHeight);
      System.Drawing.Bitmap imgOutput = new Bitmap(g,thumSize.Width,thumSize.Height);
      System.IO.MemoryStream imgStream = new MemoryStream();
      System.Drawing.Imaging.ImageFormat thisFormat = g.RawFormat;
      imgOutput.Save(imgStream, thisFormat);
      byte[] imgbin = new byte[imgStream.Length];
      imgStream.Position = 0;
      int n = imgStream.Read(imgbin,0,imgbin.Length);
      g.Dispose();
      imgOutput.Dispose();
      return imgbin;  
    }public int NewthumbSize(Double currentwidth,Double currentheight,Double newWidth, Double newHeight)
    {
      Double tempMultiplier;
      if(currentheight > currentwidth)
         tempMultiplier = newHeight / currentheight;
      else
         tempMultiplier = newWidth / currentwidth;
      System.Drawing.Size NewSize = new Size(Convert.ToInt32(currentwidth * tempMultiplier),Convert.ToInt32(currentheight * tempMultiplier));
       return NewSize;
    }