【问题标题】:Cimg Display fullscreenCimg 显示全屏
【发布时间】:2017-11-28 15:23:02
【问题描述】:

我编写了一个 C++ 程序来执行幻灯片放映,它可以在我的 ubuntu 桌面以及应该运行幻灯片放映的目标 Raspberry Pi 上按顺序和随机完美运行。

这基本上是我用来显示的代码:

#include "CImg.h"
using namespace cimg_library;
int main(int argc, char **argv) {
const char const folder = cimg_option("-i",".","Path containing pictures");
char pattern[1024];
std::snprintf(pattern,1024,"%s/.jpg",folder);
const CImgList filenames = cimg::files(pattern,true,0,true);

CImgDisplay disp(1,1,0,0,1,1);
cimglist_for(filenames,l) {
const char
*const filename = filenames[l],
*const basename = cimg::basename(filename);
const CImg img(filename);
disp.resize(cimg_fitscreen(img.width(),img.height(),1),0);
disp.display(img).set_title(basename);
if (disp.is_keyESC()) std::exit(0);
cimg::wait(3000);
}
return 0;
}"

程序运行完美,但图片没有像我想的那样全屏显示。 我认为原因取决于调整大小的配置。 我见过命令§set_fullscreen(),但我没有实现解决方案。

我想要的是在全屏下查看图片(如 Ubuntu Shotwell 照片管理器或 Raspberry Image Viewer 所做的那样)而不会变形。

我希望你能给我一个我应该如何编码的例子。 谢谢, 雷纳托·罗奇

【问题讨论】:

    标签: c++ cimg


    【解决方案1】:

    改变

    disp.resize(cimg_fitscreen(img.width(),img.height(),1),0);
    

    进入

    disp.resize(CImgDisplay::_fitscreen(img.width(),img.height(),1,0,-100,false),
                CImgDisplay::_fitscreen(img.width(),img.height(),1,0,-100,true),0);
    

    如果你想要黑色背景,添加

    CImgDisplay bg(CImgDisplay::screen_width(),CImgDisplay::screen_height(),0,0,1,0);
    

    之前

    CImgDisplay disp(1,1,0,0,1,1);
    

    【讨论】:

    • 我为延误道歉。您的建议非常有效。非常感谢。
    • 不客气。如果这个答案解决了你的问题,如果你能accept它会很好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-06
    • 2021-12-15
    相关资源
    最近更新 更多