您尚未登录。

楼主 #1 2018-02-16 12:50:31

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

离线

#2 2018-02-16 15:44:13

落雁
会员
注册时间: 2017-09-06
已发帖子: 62
积分: 62

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

buildroot 里面开启 png,把生成的libpng.so* 拷贝到文件系统试一试。

离线

#3 2018-02-16 18:11:59

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

参考网址: png-images-not-displayed-with-qt-and-visual-studio

以下是自动翻译:

在Qt支持的所有图像格式中,PNG支持是内置的,不需要任何外部插件加载。
另外,当我在预配置的开发机器上启动我的应用程序时,即使我需要任何特定的Qt插件,它也会自动加载。

我的理解:
Qt只要加载了 libpng.so*, 就可以内置支持png了。





离线

楼主 #4 2018-02-16 20:30:36

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

落雁 说:

buildroot 里面开启 png,把生成的libpng.so* 拷贝到文件系统试一试。

落雁哥,文件系上加了libpng.so*也是不能显示,是不是交叉编译是没把png图片编译进去

离线

楼主 #5 2018-02-16 20:31:58

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

参考网址: png-images-not-displayed-with-qt-and-visual-studio

以下是自动翻译:

在Qt支持的所有图像格式中,PNG支持是内置的,不需要任何外部插件加载。
另外,当我在预配置的开发机器上启动我的应用程序时,即使我需要任何特定的Qt插件,它也会自动加载。

我的理解:
Qt只要加载了 libpng.so*, 就可以内置支持png了。

晕哥,文件系上加了libpng.so*也是不能显示,是不是交叉编译是没把png图片编译进去?

离线

#6 2018-02-16 21:57:50

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

很有可能是图片路径文件, 你得缕一缕.
在ubuntu上,你用命令行,进入可执行文件的目录,
然后执行文件, 我估计也是不能显示的。





离线

#7 2018-02-16 22:01:48

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

如果上面的办法不能解决,
可以通过qrc 文件把 png等资源文件静态链接到可执行文件

参考: http://blog.csdn.net/liang19890820/article/details/51994441





离线

楼主 #8 2018-02-16 22:35:28

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

如果上面的办法不能解决,
可以通过qrc 文件把 png等资源文件静态链接到可执行文件

参考: http://blog.csdn.net/liang19890820/article/details/51994441

晕哥,上面说的不是很明白,工程中没有.qrc 文件要怎么弄呢

离线

#9 2018-02-17 00:16:42

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

新建.qrc文本文件,把内容填好,然后修改.pro工程文件,把.qrc加进去,重新qmake编译链接。





离线

楼主 #10 2018-02-17 09:18:14

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

新建.qrc文本文件,把内容填好,然后修改.pro工程文件,把.qrc加进去,重新qmake编译链接。


晕哥,好像不管用,还是不行

.pro工程文件
#-------------------------------------------------
#
# Project created by QtCreator 2018-02-15T22:18:11
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = tst
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui
#引入icon.qrc文件
RESOURCES += \
    icon.qrc
RC_FILE=icon.rc





icon.qrc文件
<RCC>
    <qresource prefix="/new/prefix1">
        <file>03.ico</file>
        <file>error_info.png</file>
    </qresource>
</RCC>






MainWindow.cpp文件

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qDebug()<<"Date:xxxxxxxxxxxxxx";
    ui->line_passwd->setEchoMode(QLineEdit::Password);
    ui->toolButton->setIcon(QIcon(":/new/prefix1/03.ico"));
    ui->toolButton_2->setIcon(QIcon(":/new/prefix1/error_info.png"));

    ui->toolButton->setIconSize(QSize(300,100));


}

win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片

离线

楼主 #11 2018-02-17 09:34:43

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥,只是用qmake编译,不知道怎样链接

离线

#12 2018-02-17 10:17:33

daydayup
会员
注册时间: 2017-10-09
已发帖子: 343
积分: 343

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

qmake project.pro
make

qmake是生成Makefile文件

离线

楼主 #13 2018-02-17 11:06:41

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
晕哥 说:

新建.qrc文本文件,把内容填好,然后修改.pro工程文件,把.qrc加进去,重新qmake编译链接。




.pro工程文件
#-------------------------------------------------
#
# Project created by QtCreator 2018-02-15T22:18:11
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = tst
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui
#引入icon.qrc文件
RESOURCES += \
    icon.qrc
RC_FILE=icon.rc





icon.qrc文件
<RCC>
    <qresource prefix="/new/prefix1">
        <file>03.ico</file>
        <file>error_info.png</file>
    </qresource>
</RCC>






MainWindow.cpp文件

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qDebug()<<"Date:xxxxxxxxxxxxxx";
    ui->line_passwd->setEchoMode(QLineEdit::Password);
    ui->toolButton->setIcon(QIcon(":/new/prefix1/03.ico"));
    ui->toolButton_2->setIcon(QIcon(":/new/prefix1/error_info.png"));

    ui->toolButton->setIconSize(QSize(300,100));


}

晕哥,daydayup哥,现在win上写的qt程序可以显示ico,gif,png图片,交叉编译后在开发板上只能显示ico,不能gif,png,jpg显图片

离线

#14 2018-02-17 11:08:37

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

我写了一个简单的demo, 你看下能否工作,专门测试当前目录的test.png有没有起作用的:

#include <QImage>
#include <iostream>

using namespace std;

int main()
{
	QImage image("test.png");
	cout << image.width() << "," << image.height() << endl;
	return 0;
}

我这里输出:

quite@ubuntu:/disk2/qimage$ ./png_test
320,240





离线

楼主 #15 2018-02-17 11:16:15

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

我写了一个简单的demo, 你看下能否工作,专门测试png有没有起作用的:

#include <QImage>
#include <iostream>

using namespace std;

int main()
{
	QImage image("test.png");
	cout << image.width() << "," << image.height() << endl;
	return 0;
}

我这里输出:

quite@ubuntu:/disk2/qimage$ ./png_test
320,240


晕哥,这是什么用软件写的,能发程序我测下吗,图片是放到什么位置呢

离线

#16 2018-02-17 11:17:08

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

然后我继续测试内嵌到资源文件

image.pro

QT       += core gui

SOURCES += \
        main.cpp 


RESOURCES += \
    icon.qrc

icon.qrc

<RCC>
    <qresource prefix="/new/prefix1">
        <file>test.png</file>
    </qresource>
</RCC>

使用内嵌的test.png 文件:

#include <QImage>
#include <iostream>

using namespace std;

int main()
{
	QImage image(":/new/prefix1/test.png");
	cout << image.width() << "," << image.height() << endl;
	return 0;
}

输出仍然是正常:
quite@ubuntu:/disk2/qimage$ ./png_test
320,240





离线

#17 2018-02-17 11:22:57

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:

晕哥,这是什么用软件写的,能发程序我测下吗,图片是放到什么位置呢

和可执行文件放在一个目录即可.





离线

楼主 #18 2018-02-17 11:31:07

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:
zhuacai 说:

晕哥,这是什么用软件写的,能发程序我测下吗,图片是放到什么位置呢

和可执行文件放在一个目录即可.


晕哥,读不出来

#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage(":/new/prefix1/error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    return a.exec();
}


# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

离线

楼主 #19 2018-02-17 11:40:14

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
晕哥 说:
zhuacai 说:

晕哥,这是什么用软件写的,能发程序我测下吗,图片是放到什么位置呢

和可执行文件放在一个目录即可.


晕哥,读不出来

#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage(":/new/prefix1/error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    return a.exec();
}


# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage(":/new/prefix1/error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    QImage inage2(":/new/prefix1/03.ico");
    qDebug()<<inage2.width()<<","<<inage2.height()<<endl;

    return a.exec();
}

晕哥,可以读出ioc,png读不出来

# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

152 , 152

离线

#20 2018-02-17 11:41:35

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

不用内嵌那种方式呢?





离线

楼主 #21 2018-02-17 14:26:45

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

不用内嵌那种方式呢?


#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage("error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    QImage inage2("03.ico");
    qDebug()<<inage2.width()<<","<<inage2.height()<<endl;

    return a.exec();
}



晕哥,也是一样只能读ico
# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

152 , 152

^C# ^C
# rm 03.ico
# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

0 , 0

离线

#22 2018-02-17 15:14:17

daydayup
会员
注册时间: 2017-10-09
已发帖子: 343
积分: 343

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

上面这个在电脑上正常吧?
感觉你的嵌入式系统的libpng库出问题了。

离线

楼主 #23 2018-02-17 15:45:12

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:

上面这个在电脑上正常吧?
感觉你的嵌入式系统的libpng库出问题了。

感谢daydayup的回答,对是嵌入式系统的libpng库出问题了
开始我以为是缺libpng库,就直接用buildroot编译libpng库拷到开发板上,也不行,原来QT是用的Q库,就是libpng.os
export QT_PLUGIN_PATH=/usr/lib/qt/plugins/下面的imageformats下面没有对应的libpng.so,libqgif.so,libqjpeg.so库,
然后在liunx交叉qt5.9.1后把/home/clark/QtEnv/QtEmbedded-5.9.1-arm/plugins/imageformats下面libpng.so,libqgif.so,libqjpeg.so库拷到开发板上的/usr/lib/qt/plugins/imageformats下面的就可以了

离线

#24 2018-02-17 15:59:12

daydayup
会员
注册时间: 2017-10-09
已发帖子: 343
积分: 343

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

哈,解决了就好,给后来到这里的朋友提供了一个解决思路。
我觉得把 libpng* 拷贝到/usr/lib 里面应该也是可以的。

离线

楼主 #25 2018-02-17 17:24:52

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:

哈,解决了就好,给后来到这里的朋友提供了一个解决思路。
我觉得把 libpng* 拷贝到/usr/lib 里面应该也是可以的。

daydayup哥,我上面说错了,现在发现没有libpng.so,只有libqicns.so  libqjpeg.so  libqtga.so   libqwbmp.so libqgif.so   libqico.so   libqsvg.so   libqtiff.so  libqwebp.so 所以还是不能显示png图片,只能显示gif,ico,jpg图片,网上查了一下说QT5内置支持png,但是不知道怎样才能显示png图片,还
请大神们帮忙

离线

#26 2018-02-17 17:40:57

daydayup
会员
注册时间: 2017-10-09
已发帖子: 343
积分: 343

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
daydayup 说:

哈,解决了就好,给后来到这里的朋友提供了一个解决思路。
我觉得把 libpng* 拷贝到/usr/lib 里面应该也是可以的。

daydayup哥,我上面说错了,现在发现没有libpng.so,只有libqicns.so  libqjpeg.so  libqtga.so   libqwbmp.so libqgif.so   libqico.so   libqsvg.so   libqtiff.so  libqwebp.so 所以还是不能显示png图片,只能显示gif,ico,jpg图片,网上查了一下说QT5内置支持png,但是不知道怎样才能显示png图片,还
请大神们帮忙

内置支持png的意思是,不再需要比如qgif,qjpeg类似的插件,但是libpng.so*一定是需要的。
如果把libpng.so*拷贝到/usr/lib应该可以吧?

离线

楼主 #27 2018-02-17 18:05:19

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:
zhuacai 说:
daydayup 说:

哈,解决了就好,给后来到这里的朋友提供了一个解决思路。
我觉得把 libpng* 拷贝到/usr/lib 里面应该也是可以的。

daydayup哥,我上面说错了,现在发现没有libpng.so,只有libqicns.so  libqjpeg.so  libqtga.so   libqwbmp.so libqgif.so   libqico.so   libqsvg.so   libqtiff.so  libqwebp.so 所以还是不能显示png图片,只能显示gif,ico,jpg图片,网上查了一下说QT5内置支持png,但是不知道怎样才能显示png图片,还
请大神们帮忙

内置支持png的意思是,不再需要比如qgif,qjpeg类似的插件,但是libpng.so*一定是需要的。
如果把libpng.so*拷贝到/usr/lib应该可以吧?

daydayup哥,libpng.so*拷贝/usr/lib下了还是不行

# find / -name libpng*
/usr/lib/libpng16.so.16.31.0
/usr/lib/qt/plugins/imageformats/libpng.so
/usr/lib/libpng.so
/usr/lib/libpng16.so
/usr/lib/libpng16.so.16

离线

楼主 #28 2018-02-17 18:42:10

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

Qt 5.9帮助文档看到的不是很明白说什么

Qt 5.9
Qt GUI
LibPNG

Qt 5.9.1 Reference Documentation

LibPNG
libpng is the official PNG reference library.
Used in the qpng image plugin. Configure with -system-png or -no-png to avoid.
The sources can be found in qtbase/src/3rdparty/libpng.
Project Homepage, upstream version: 1.6.28

  Copyright (c) 1998-2017 Glenn Randers-Pehrson
  Copyright (c) 2000-2017 Simon-Pierre Cadieux
  Copyright (c) 2000-2017 Eric S. Raymond
  Copyright (c) 2000-2017 Mans Rullgard
  Copyright (c) 2000-2017 Cosmin Truta
  Copyright (c) 2000-2017 Gilles Vollant
  Copyright (c) 2000-2017 James Yu
  Copyright (c) 2000-2017 Mandar Sahastrabuddhe
  Copyright (c) 1998-2000 Tom Lane
  Copyright (c) 1998-2000 Willem van Schaik
  Copyright (c) 1996-1997 Andreas Dilger
  Copyright (c) 1996-1997 John Bowler
  Copyright (c) 1996-1997 Kevin Bracey
  Copyright (c) 1996-1997 Sam Bushell
  Copyright (c) 1996-1997 Magnus Holmgren
  Copyright (c) 1996-1997 Greg Roelofs
  Copyright (c) 1996-1997 Tom Tanner
  Copyright (c) 1995-1996 Dave Martindale
  Copyright (c) 1995-1996 Paul Schmidt
  Copyright (c) 1995-1996 Tim Wegner
  Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.

libpng License.

  This copy of the libpng notices is provided for your convenience.  In case of
  any discrepancy between this copy and the notices in the file png.h that is
  included in the libpng distribution, the latter shall prevail.

  COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:

  If you modify libpng you may insert additional notices immediately following
  this sentence.

  This code is released under the libpng license.

  libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
  Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
  derived from libpng-1.0.6, and are distributed according to the same
  disclaimer and license as libpng-1.0.6 with the following individuals
  added to the list of Contributing Authors:

     Simon-Pierre Cadieux
     Eric S. Raymond
     Mans Rullgard
     Cosmin Truta
     Gilles Vollant
     James Yu
     Mandar Sahastrabuddhe

  and with the following additions to the disclaimer:

     There is no warranty against interference with your enjoyment of the
     library or against infringement.  There is no warranty that our
     efforts or the library will fulfill any of your particular purposes
     or needs.  This library is provided with all faults, and the entire
     risk of satisfactory quality, performance, accuracy, and effort is with
     the user.

  Some files in the "contrib" directory and some configure-generated
  files that are distributed with libpng have other copyright owners and
  are released under other open source licenses.

  libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  libpng-0.96, and are distributed according to the same disclaimer and
  license as libpng-0.96, with the following individuals added to the list
  of Contributing Authors:

     Tom Lane
     Glenn Randers-Pehrson
     Willem van Schaik

  libpng versions 0.89, June 1996, through 0.96, May 1997, are
  Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
  and are distributed according to the same disclaimer and license as
  libpng-0.88, with the following individuals added to the list of
  Contributing Authors:

     John Bowler
     Kevin Bracey
     Sam Bushell
     Magnus Holmgren
     Greg Roelofs
     Tom Tanner

  Some files in the "scripts" directory have other copyright owners
  but are released under this license.

  libpng versions 0.5, May 1995, through 0.88, January 1996, are
  Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.

  For the purposes of this copyright and license, "Contributing Authors"
  is defined as the following set of individuals:

     Andreas Dilger
     Dave Martindale
     Guy Eric Schalnat
     Paul Schmidt
     Tim Wegner

  The PNG Reference Library is supplied "AS IS".  The Contributing Authors
  and Group 42, Inc. disclaim all warranties, expressed or implied,
  including, without limitation, the warranties of merchantability and of
  fitness for any purpose.  The Contributing Authors and Group 42, Inc.
  assume no liability for direct, indirect, incidental, special, exemplary,
  or consequential damages, which may result from the use of the PNG
  Reference Library, even if advised of the possibility of such damage.

  Permission is hereby granted to use, copy, modify, and distribute this
  source code, or portions hereof, for any purpose, without fee, subject
  to the following restrictions:

    1. The origin of this source code must not be misrepresented.

    2. Altered versions must be plainly marked as such and must not
       be misrepresented as being the original source.

    3. This Copyright notice may not be removed or altered from any
       source or altered source distribution.

  The Contributing Authors and Group 42, Inc. specifically permit, without
  fee, and encourage the use of this source code as a component to
  supporting the PNG file format in commercial products.  If you use this
  source code in a product, acknowledgment is not required but would be
  appreciated.

  END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.

  TRADEMARK:

  The name "libpng" has not been registered by the Copyright owner
  as a trademark in any jurisdiction.  However, because libpng has
  been distributed and maintained world-wide, continually since 1995,
  the Copyright owner claims "common-law trademark protection" in any
  jurisdiction where common-law trademark is recognized.

  OSI CERTIFICATION:

  Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
  a certification mark of the Open Source Initiative. OSI has not addressed
  the additional disclaimers inserted at version 1.0.7.

  EXPORT CONTROL:

  The Copyright owner believes that the Export Control Classification
  Number (ECCN) for libpng is EAR99, which means not subject to export
  controls or International Traffic in Arms Regulations (ITAR) because
  it is open source, publicly available software, that does not contain
  any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
  734.7(b).

  Glenn Randers-Pehrson
  glennrp at users.sourceforge.net
  January 5, 2017

离线

#29 2018-02-17 18:56:17

daydayup
会员
注册时间: 2017-10-09
已发帖子: 343
积分: 343

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

那现在问题解决了吗?
你去buildroot Qt配置那里看下是不是没勾png?

离线

楼主 #30 2018-02-17 21:19:56

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:

那现在问题解决了吗?
你去buildroot Qt配置那里看下是不是没勾png?


daydayup哥,Qt配置里的png己经勾了,现在还是不能显示png图片

离线

#31 2018-02-17 21:32:44

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
daydayup 说:

那现在问题解决了吗?
你去buildroot Qt配置那里看下是不是没勾png?


daydayup哥,Qt配置里的png己经勾了,现在还是不能显示png图片

严重怀疑板上的libpng有问题,你弄个简单的png test demo试一试就知道libpng是否正确了。





离线

#32 2018-02-17 21:39:09

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

http://zarb.org/~gc/html/libpng.html
你把这个demo在电脑上跑一下试一试,
然后再到板子上再试,
如果板子不行,
那么肯定是板子的libpng出问题了。





离线

楼主 #33 2018-02-17 22:43:35

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

http://zarb.org/~gc/html/libpng.html
你把这个demo在电脑上跑一下试一试,
然后再到板子上再试,
如果板子不行,
那么肯定是板子的libpng出问题了。

晕哥,上面demo怎样编译呢,编译时找不到png.h这个头文件呢

离线

#34 2018-02-18 09:08:40

daydayup
会员
注册时间: 2017-10-09
已发帖子: 343
积分: 343

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

Ubuntu安装库:

sudo apt-get install libpng-dev

参考: https://stackoverflow.com/questions/36674667/png-h-file-not-found-linux

离线

楼主 #35 2018-02-18 23:08:18

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:
zhuacai 说:
daydayup 说:

那现在问题解决了吗?
你去buildroot Qt配置那里看下是不是没勾png?


daydayup哥,Qt配置里的png己经勾了,现在还是不能显示png图片

严重怀疑板上的libpng有问题,你弄个简单的png test demo试一试就知道libpng是否正确了。


晕哥,liunx上装了QtCreator然后然后编译在win上写的工程,在liunx上可以显示png图片

离线

#36 2018-02-19 09:23:38

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

是用32楼的代码吗?





离线

楼主 #37 2018-02-19 10:53:20

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

是用32楼的代码吗?


晕哥,不是,不知道怎样编译32楼的demo,我用gcc xxx.c -o xxx 编译提示找不到png.h头文件,用-I指定了png头文件,又出现很多错误,

离线

楼主 #38 2018-02-19 10:54:36

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
晕哥 说:

是用32楼的代码吗?


晕哥,不是,不知道怎样编译32楼的demo,我用gcc xxx.c -o xxx 编译提示找不到png.h头文件,用-I指定了png头文件,又出现很多错误,所以liunx上装了QtCreator然后编译在win上写的工程,在liunx上可以显示png图片

离线

#39 2018-02-19 11:18:32

daydayup
会员
注册时间: 2017-10-09
已发帖子: 343
积分: 343

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
zhuacai 说:
晕哥 说:

是用32楼的代码吗?


晕哥,不是,不知道怎样编译32楼的demo,我用gcc xxx.c -o xxx 编译提示找不到png.h头文件,用-I指定了png头文件,又出现很多错误,所以liunx上装了QtCreator然后编译在win上写的工程,在liunx上可以显示png图片

用34# 楼的方法试一试。

离线

楼主 #40 2018-02-19 11:41:08

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:
zhuacai 说:
zhuacai 说:

晕哥,不是,不知道怎样编译32楼的demo,我用gcc xxx.c -o xxx 编译提示找不到png.h头文件,用-I指定了png头文件,又出现很多错误,所以liunx上装了QtCreator然后编译在win上写的工程,在liunx上可以显示png图片

用34# 楼的方法试一试。


daydayup哥,安装apt-get install libpng-dev编译提示还找不到png.h头文件

离线

#41 2018-02-19 12:27:31

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

不会啊,我的正常哦。

sudo apt-get install libpng-dev
sudo apt-get install libpng12-dev

$ find /usr/ |grep png.h
/usr/include/png.h
/usr/include/libpng12/png.h

编译运行演示代码:

$gcc -o test test.c -lpng

$ ./test
Usage: program_name <file_in> <file_out>





离线

楼主 #42 2018-02-19 18:52:00

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

不会啊,我的正常哦。

sudo apt-get install libpng-dev
sudo apt-get install libpng12-dev

$ find /usr/ |grep png.h
/usr/include/png.h
/usr/include/libpng12/png.h

编译运行演示代码:

$gcc -o test test.c -lpng

$ ./test
Usage: program_name <file_in> <file_out>


晕哥,在liunx纺译通过了输出以[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (6) (is 3)

root@ubuntu:/home/vv3/qt5# ./tty tst/03.png 04.png
[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (6) (is 3)
Aborted (core dumped)


用arm-linux-gnueabihf-gcc编译器交叉编译出错了,是什么问题呢
root@ubuntu:/home/vv3/qt5# arm-linux-gnueabihf-gcc -o tty tty.c -I/home/vv3/Downloads/buildroot-2017.08.1/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include -L/home/vv3/Downloads/buildroot-2017.08.1/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/libc.so.6
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find /usr/lib/libc_nonshared.a
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/ld-linux-armhf.so.3
collect2: error: ld returned 1 exit status
root@ubuntu:/home/vv3/qt5#

离线

#43 2020-02-21 02:54:32

kakalu
会员
注册时间: 2020-02-11
已发帖子: 16
积分: 0.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

我也遇到了这个问题了,还没有搞定啊

离线

#44 2020-02-21 08:44:11

Jmhh247
会员
注册时间: 2018-12-21
已发帖子: 262
积分: 262

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

kakalu 说:

我也遇到了这个问题了,还没有搞定啊

可以写个最简单的程序测试下qt支持的图片格式:

- 测试代码:

#include <QImageReader>

qDebug() << QImageReader::supportedImageFormats();

- ubuntu下测试输出:

("bmp", "cur", "gif", "ico", "jpeg", "jpg", "pbm", "pgm", "png", "ppm", "xbm", "xpm")

- 交叉编译后在你的开发板上测试。

离线

#45 2020-02-21 08:52:32

红白机
会员
注册时间: 2020-01-02
已发帖子: 133
积分: 133

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

楼上这个办法好!

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn