PDA

View Full Version : ERROR Pixmap loadFromData with JPEG processing



kalpa
13th November 2006, 08:58
Good day.
Let me describe the problem.
I am using QByteArray to send pixmap information between client and server.
All Was OK.
But now the same code doesn't work correctly on Windows platform, but working good on Linux.
This sample works with png image files but with JPEG I have problems in Windows.
Can you help me to fix this problem.

qt4.2.0 qt4.2.1 (tested)
gcc 4.1.1(linux)
MinGW 3.4.2( Window)

Can you help me.
I sent this information to qt-bugs but I think they have so much to do. (And Week end)



include <QDebug>
#include <QApplication>
#include <QWidget>
#include <QBrush>
#include <QPalette>
#include <QFile>
#include <QMessageBox>

int main(int argc, char** argv)
{
QApplication App(argc, argv);
QBrush Brush;
QPixmap Pixmap;
QPalette Palette;
QByteArray bArray;

QFile PixmapFile("./testimage.jpg");
if(!PixmapFile.open(QIODevice::ReadOnly))
{
qDebug("Error loading Pixmap");
return false;
}

bArray=PixmapFile.readAll().toBase64();

if(!Pixmap.loadFromData( bArray.fromBase64(bArray)))
{
qDebug()<<"Error pixmap processing";
return 0;
}

QWidget *tWidget=new QWidget();

Brush.setTexture(Pixmap );

Palette.setBrush(QPalette::Background, Brush);
tWidget->setPalette( Palette);

tWidget->show();
App.exec();
}

wysota
13th November 2006, 09:01
Is the file a correct JPEG image? Do other image processing applications open it without problems?

kalpa
13th November 2006, 09:20
Is the file a correct JPEG image? Do other image processing applications open it without problems?

Yes, of course. I used standard kde wallpapers for testing.
Just Try this code in Windows. In Linux the same code works with no problems.

jpn
13th November 2006, 09:35
Have you tried with an absolute path to the file?

kalpa
13th November 2006, 09:40
Have you tried with an absolute path to the file?
I am not a newbe in Qt.
Just test this code. If you replace "foo.jpg" to "bar.png" everything will be OK.
I don't think that image processing depends on absolute path.

jpn
13th November 2006, 09:46
Well, I did test and it worked just fine for me with a jpeg. Using Qt 4.2.1 + MSVC 2005 here..

kalpa
13th November 2006, 10:11
I tested again and again.
For my MinGW and GPL version of Qt 4.2.1 the situation is not so wonderful.
Error JPEG Image Processing.

wysota
13th November 2006, 10:34
Have you tried with different jpeg images? Are you sure they are ACTUALLY jpeg (don't look at the file extension)? Qt depends on libjpeg to process jpeg images, so there is no reason for it to fail if other libjpeg-dependent applications are able to load the image. Also remember to open the file in binary format, maybe that's your problem that line endings get converted and the data is corrupted...

kalpa
13th November 2006, 16:08
Trolls agree with me and open a bug in the tracker.

http://www.trolltech.com/developer/task-tracker/index_html?id=138915&method=entry