2011-08-05 101 views
0

我想在这里调用静态函数cropImage是如何看起来..需要帮助下面的代码片段

public static Image CropImage(Image img, Rectangle cropArea) 
{ 
     logic goes here.. 
} 

我想这个函数调用作物上午形象我怎么能做到这一点? 当我试图这样

Rectangle objRect=new Rectangle(20,10,200,100); 
static_className.CropImage(image,objRect); 

我得到了一个错误说无效的参数。

+2

检查'image'的类型 –

+1

请发布* exact *错误消息,理想情况下更多的上下文(例如'image'的类型)。请注意,C#区分大小写,因此在调用代码中'cropImage'应该是'CropImage'。 –

+0

另外,请编辑您的问题的标题。这是一个非常通用的标题,并没有用处。 – shashi

回答

0
Image oldImg; 

Rectangle objrect=new Rectangle(20,10,200,100); 
Image newImage=static_className.cropImage(oldImg,objrect); 
+0

我已经使用上传控件将图像和转换后的图像上传到字节流,现在我怎样才能将它作为参数传递给CropImage函数, – asif

+0

使用[Image .FromStream](http://msdn.microsoft.com/en-us/library/93z9ee4x.aspx)将流加载到Image对象中,然后将Image对象传递给'CropImage'方法。 – Tim