Results 1 to 9 of 9

Thread: ERROR Pixmap loadFromData with JPEG processing

  1. #1
    Join Date
    Nov 2006
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation ERROR Pixmap loadFromData with JPEG processing

    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)

    Qt Code:
    1. include <QDebug>
    2. #include <QApplication>
    3. #include <QWidget>
    4. #include <QBrush>
    5. #include <QPalette>
    6. #include <QFile>
    7. #include <QMessageBox>
    8.  
    9. int main(int argc, char** argv)
    10. {
    11. QApplication App(argc, argv);
    12. QBrush Brush;
    13. QPixmap Pixmap;
    14. QPalette Palette;
    15. QByteArray bArray;
    16.  
    17. QFile PixmapFile("./testimage.jpg");
    18. if(!PixmapFile.open(QIODevice::ReadOnly))
    19. {
    20. qDebug("Error loading Pixmap");
    21. return false;
    22. }
    23.  
    24. bArray=PixmapFile.readAll().toBase64();
    25.  
    26. if(!Pixmap.loadFromData( bArray.fromBase64(bArray)))
    27. {
    28. qDebug()<<"Error pixmap processing";
    29. return 0;
    30. }
    31.  
    32. QWidget *tWidget=new QWidget();
    33.  
    34. Brush.setTexture(Pixmap );
    35.  
    36. Palette.setBrush(QPalette::Background, Brush);
    37. tWidget->setPalette( Palette);
    38.  
    39. tWidget->show();
    40. App.exec();
    41. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    Is the file a correct JPEG image? Do other image processing applications open it without problems?

  3. #3
    Join Date
    Nov 2006
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    Quote Originally Posted by wysota View Post
    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    Have you tried with an absolute path to the file?
    J-P Nurmi

  5. #5
    Join Date
    Nov 2006
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    Quote Originally Posted by jpn View Post
    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.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    Well, I did test and it worked just fine for me with a jpeg. Using Qt 4.2.1 + MSVC 2005 here..
    J-P Nurmi

  7. #7
    Join Date
    Nov 2006
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    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...

  9. #9
    Join Date
    Nov 2006
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ERROR Pixmap loadFromData with JPEG processing

    Trolls agree with me and open a bug in the tracker.

    http://www.trolltech.com/developer/t...5&method=entry
    Last edited by kalpa; 13th November 2006 at 16:20.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.