简体   繁体   English

重定向 libpng 警告 C++

[英]Redirecting libpng warnings C++

I'm trying to create a program in c++ using libpng, it just compares images and does stuff with it, my problem is that libpng sometimes shows a warning (libpng warning: iCCP: known incorrect sRGB profile), I know how to solve it using ImageMagick library and an external script, what I want to know is if a) Can I redirect that warning?我正在尝试使用 libpng 在 c++ 中创建一个程序,它只是比较图像并用它做一些事情,我的问题是 libpng 有时会显示警告(libpng 警告:iCCP:已知不正确的 sRGB 配置文件),我知道如何解决它使用 ImageMagick 库和外部脚本,我想知道是否 a) 我可以重定向该警告吗? I tried redirecting cout, clog and cerr but the message still prints (I tested it and it blocks any other print I try), and b) Is there a way correct the warning using Opencv2 and c++?我尝试重定向 cout、clog 和 cerr,但消息仍然打印(我对其进行了测试,它阻止了我尝试的任何其他打印),并且 b)有没有办法使用 Opencv2 和 c++ 更正警告?

EDIT: After looking at png_set_error_fn() and finding out there's no way for me to use it with opencv2, I looked for the buffer that uses libpng to print errors and warnings, it uses stderr and redirected it using:编辑:查看 png_set_error_fn() 并发现我无法将它与 opencv2 一起使用后,我寻找了使用 libpng 打印错误和警告的缓冲区,它使用 stderr 并使用以下命令重定向它:

    const char* nullStream = "/dev/null";
    #ifdef "WIN32"
    nullStream = "nul:";
    #endif
    freopen(nullStream,"w",stderr);

After a quick Google, seems like libpng supports redirection of errors and warnings into your own callback, png_set_error_fn is the setter you are looking for.在快速谷歌之后,似乎 libpng 支持将错误和警告重定向到您自己的回调中, png_set_error_fn是您正在寻找的设置器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM