c – 对每个以逗号分隔的对象执行成员函数
发布时间:2020-12-16 07:34:42 所属栏目:百科 来源:网络整理
导读:以下是 full listing的相关代码: #include "CImg.h"using namespace cimg_library;int main() { CImgunsigned char src("Tulips.jpg"); int width = src.width(); int height = src.height(); int depth = src.depth(); //New grayscale images. CImgunsign
以下是
full listing的相关代码:
#include "CImg.h" using namespace cimg_library; int main() { CImg<unsigned char> src("Tulips.jpg"); int width = src.width(); int height = src.height(); int depth = src.depth(); //New grayscale images. CImg<unsigned char> gray1(width,height,depth,1); CImg<unsigned char> gray2(width,1); // ... (src,gray1,gray2).display("RGB to Grayscale"); } 线条如何(src,gray2).display(“RGB to Grayscale”);工作?如何将显示成员函数应用于逗号分隔列表中的每个对象? 解决方法CImg 重载operator,它返回一个
CImgList 对象,该对象是一个包含作为操作数给出的两个CImg对象的列表.该对象还会重载运算符,以允许将CImg对象添加到列表中.
表达式(src,gray2)等价于((src,gray1),gray2).内部括号集(src,gray1)创建CImgList,然后(…,gray2)将gray2追加到该列表,返回对同一列表的引用. CImgList具有成员函数显示. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |