如何使用CIMG.H库在另一个图像上显示一个图像
How do I display one image over the other using CImg.h library?
我试图通过另一个图像显示一个图像,但在同一窗口中。我已经看到帖子并排工作,但我已经知道该怎么做。这是我到目前为止所拥有的:
string firstFile = "";
string secondFile = "";
cout << "Enter the filenames corresponding to the Image and the Logo (in that order): " << endl;
cin >> firstFile;
cin >> secondFile;
const char* filename = firstFile.c_str();
CImg<unsigned char> img1(filename);
const char* filename2 = secondFile.c_str();
CImg<unsigned char> img2(filename2);
int w = img1.width();
int h = img1.height();
int channels = img1.spectrum();
cout << "Successfully loaded image " << firstFile << " of size " << w << " x " << h << " x " << channels << endl;
int w2 = img2.width();
int h2 = img2.height();
channels = img2.spectrum();
cout << "Successfully loaded image " << secondFile << " of size " << w2 << " x " << h2 << " x " << channels << endl;
cout << "Enter the position in (x, y) coordinates where this logo must be placed." << endl << "x must be between 0 and 239 and y must be between 0 and 191." << endl;
int x1, y1;
cin >> x1;
cin >> y1;
char title[100];
sprintf(title, "%s (%d x %d x %d)", filename, w, h, channels);
CImgDisplay disp(img1, title, 0);
img1.display(disp, false);
这样:
// Draw img2 on top of img1 at (x1,y1)
img1.draw_image(x1,y1,img2);
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 如果不在窗口 10 中声明名为 openCV 的 openCV namedWindow,QT 图像显示将无法正常工作
- 我在 OpenGL 中显示图像时遇到问题
- C++ 窗口显示无框图像
- 裁剪并显示我从哈尔级联获得的图像
- 如何显示具有 opengl 纹理的灰度图像
- 使用 Splashkit 逐个显示多个C++图像
- 如何使用OpenCV同时显示"深度"和"颜色"视频图像
- 如何从amd gpus的显示输出中获取图像数据
- Qt-png图像未显示在部署应用程序中
- 无法在 Opencv 中显示图像导致内存位置
- 只有左侧图像显示在OpenGL Stereo上
- gstreamer 管道代码,用于通过来自相机的实时流式传输而不是图像显示文本
- wxnotebook动态图像显示
- OpenCV-关闭图像显示窗口
- Qt拖放-改变图像显示,而拖动
- 为什么从Project Tango Tablet中提取的图像显示为灰色
- 如果同时运行两次wkhtmltopdf库,为什么它只会发生数据文档,而没有任何表或图像显示在html文件中
- 如何在win32中刷新图像显示白色,保持文字不变