位图方法clone(位图,格式)将无法编译 [英] Bitmap method clone(bitmap, format) will not compile

查看:163
本文介绍了位图方法clone(位图,格式)将无法编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

clone(Bitmap,format)编译器说没有重载需要2个参数



Microsoft docs描述了net frameworks 1.2 to的方法(有2个参数) 4.7.2



Bitmap.Clone Method(System.Drawing)| Microsoft Docs [ 4.5 #System_Drawing_Bitmap_Clone_System_Drawing_Rectangle_System_Drawing_Imaging_PixelFormat_target =_ blanktitle =New Window> ^ ])



我正在使用框架4.5和visual studio 2012 Express



我在互联网上搜索但没有找到任何关于这样的问题的参考



我缺少什么?



我尝试了什么:



我一直无法找到任何方法强制编译器接受方法调用

clone(Bitmap,format) Compiler say there is no overload that takes 2 arguments

Microsoft docs describes the method ( with 2 arguments) for net frameworks 1.2 to 4.7.2

(Bitmap.Clone Method (System.Drawing) | Microsoft Docs[^])

I am using framework 4.5 and visual studio 2012 Express

I have searched the internet but have not found any reference to such a problem

what am i missing?

What I have tried:

I haven't been able to find any way to force the compiler to accept the method call

推荐答案

你缺少一些括号。



You're missing some parenthesis.

newImage = ((Bitmap)image).Clone(sRec,PixelFormat.Format16bppArgb1555);





在原始代码中



(位图)image.Clone



你在任何类型的图像上调用Clone方法,你没有在图像转换为Bitmap时调用它。通过添加括号,您将在将图像投射到位图的结果上调用Clone。



In your original code

"(Bitmap)image.Clone"

You are calling the Clone method on whatever type image is, you're not calling it on image cast to Bitmap. By adding the parenthesis you are calling Clone on the result of casting image to Bitmap.


编辑





源代码行是: -



newImage =(Bitmap)image.Clone(sRec,PixelFormat.Format16bppArgb1555);



newImage在类Form1中定义:Form by: -



Bitmap newImage = null;



编译器消息是: -



'错误:

无过载方法Clone需要2个参数'
Edit


the source line is:-

newImage = (Bitmap)image.Clone(sRec,PixelFormat.Format16bppArgb1555);

newImage is defined in the class Form1 : Form by:-

"Bitmap newImage = null;"

The compiler message was:-

'Error:
No overload for method "Clone" takes 2 arguments'


我现在用Visual Studio 2017测试了它



编译确定 - 没有错误消息
I have now tested this with Visual Studio 2017

Compiles OK - no error message


这篇关于位图方法clone(位图,格式)将无法编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆