在c ++上打开图像文件,PNG,JPEG [英] opening image file on c++ , PNG , JPEG

查看:95
本文介绍了在c ++上打开图像文件,PNG,JPEG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试打开bg.png文件,但是没有用。没有错误,但是什么也没有出现。

I have tried to open bg.png file , but didn't work. There is no error , but nothing appears. Help Me!

int main()
    {
        initwindow(600,600,"GAME");
        ifstream image("bg.png");
        getimage(50, 50 , 450 , 450 , image);
        putimage(50,50,image,COPY_PUT);
        system("pause");
    }


推荐答案

此:

ifstream image("bg.png");

…在文本模式中打开文件,在Windows和旧Mac上,其中表示行尾和文本结尾的某些字节序列在输入和输出上被更改。

… opens the file in text mode, where, in Windows and on old Macs, certain byte sequences denoting end-of-line and end-of-text, are changed on input and output.

您不要那样。

指定二进制模式

也就是说,您最接近标准 C ++中的图像处理是 Boost图像库

That said, the closest you get to “standard” image handling in C++ is the Boost Image library.

这篇关于在c ++上打开图像文件,PNG,JPEG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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