Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImage doesn't take in a JPG
Forum Updated to NodeBB v4.3 + New Features

QImage doesn't take in a JPG

Scheduled Pinned Locked Moved Solved General and Desktop
30 Posts 5 Posters 10.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rapidrain
    wrote on last edited by
    #1

    I have two photos, f1.bmp and f1.jpg each at 4608 x 3456 pixels

    Using this I can see the photo appear in MyLabel derived from QLabel

    QImage* image = new QImage();
    image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.bmp", Q_NULLPTR);
    setPixmap(QPixmap::fromImage(*image));
    

    the f1.bmp is enormous so it shows the upper left corner in my 600 x 450 MyLabel.

    shrinking to f2.bmp (600 x 450) fits perfectly.

    However a jpg of the very same photo (converted by PaintShopPro) never, never, ever
    appears.

    QImage* image = new QImage();
    	bool b1 = image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.jpg", "jpeg");
    	if (b1 == true) {
    
    		std::cout << "true " << std::endl;
    	}
    	else {
                    // this guy always appears for *.jpg
    		std::cout << "false " << std::endl;
    	}
    	setPixmap(QPixmap::fromImage(*image));
    

    shrinking the jpg down to 600 x 450 or 595 x 446 or 500 x 375 doesn't help

    Documentation says I need to write a const char* to indicate format.....I've tried "JPG" "jpg" "jpeg" and "JPEG".
    nothing works!!!

    How do I make QImage swallow a jpg??

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • R Rapidrain

      I have two photos, f1.bmp and f1.jpg each at 4608 x 3456 pixels

      Using this I can see the photo appear in MyLabel derived from QLabel

      QImage* image = new QImage();
      image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.bmp", Q_NULLPTR);
      setPixmap(QPixmap::fromImage(*image));
      

      the f1.bmp is enormous so it shows the upper left corner in my 600 x 450 MyLabel.

      shrinking to f2.bmp (600 x 450) fits perfectly.

      However a jpg of the very same photo (converted by PaintShopPro) never, never, ever
      appears.

      QImage* image = new QImage();
      	bool b1 = image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.jpg", "jpeg");
      	if (b1 == true) {
      
      		std::cout << "true " << std::endl;
      	}
      	else {
                      // this guy always appears for *.jpg
      		std::cout << "false " << std::endl;
      	}
      	setPixmap(QPixmap::fromImage(*image));
      

      shrinking the jpg down to 600 x 450 or 595 x 446 or 500 x 375 doesn't help

      Documentation says I need to write a const char* to indicate format.....I've tried "JPG" "jpg" "jpeg" and "JPEG".
      nothing works!!!

      How do I make QImage swallow a jpg??

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Rapidrain Did you verify that this jpeg image is valid - open it in an image viewer?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      2
      • jsulmJ jsulm

        @Rapidrain Did you verify that this jpeg image is valid - open it in an image viewer?

        R Offline
        R Offline
        Rapidrain
        wrote on last edited by
        #3

        @jsulm : "open it in an image viewer" --- do you mean look at the picture with an app like MS Paint??

        or do you mean use another class in Qt to ascertain its format????

        jsulmJ 1 Reply Last reply
        0
        • R Rapidrain

          @jsulm : "open it in an image viewer" --- do you mean look at the picture with an app like MS Paint??

          or do you mean use another class in Qt to ascertain its format????

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Rapidrain I mean open it in any image viewer or MS Paint or whatever

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Rapidrain I mean open it in any image viewer or MS Paint or whatever

            R Offline
            R Offline
            Rapidrain
            wrote on last edited by
            #5

            @jsulm I just tried it with

            1. Fotos
            2. Paint
            3. Paint 3D
            4. Paint Shop Pro 7

            all show the image of f1.jpg

            jsulmJ 1 Reply Last reply
            0
            • R Rapidrain

              @jsulm I just tried it with

              1. Fotos
              2. Paint
              3. Paint 3D
              4. Paint Shop Pro 7

              all show the image of f1.jpg

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Rapidrain Some question:

              1. How did you install Qt (is it your own build or precompiled binary)?
              2. Not related to your problem: why do you allocate image on the heap using new operator (QImage image; would be enough)?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              R 1 Reply Last reply
              0
              • R Rapidrain

                I have two photos, f1.bmp and f1.jpg each at 4608 x 3456 pixels

                Using this I can see the photo appear in MyLabel derived from QLabel

                QImage* image = new QImage();
                image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.bmp", Q_NULLPTR);
                setPixmap(QPixmap::fromImage(*image));
                

                the f1.bmp is enormous so it shows the upper left corner in my 600 x 450 MyLabel.

                shrinking to f2.bmp (600 x 450) fits perfectly.

                However a jpg of the very same photo (converted by PaintShopPro) never, never, ever
                appears.

                QImage* image = new QImage();
                	bool b1 = image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.jpg", "jpeg");
                	if (b1 == true) {
                
                		std::cout << "true " << std::endl;
                	}
                	else {
                                // this guy always appears for *.jpg
                		std::cout << "false " << std::endl;
                	}
                	setPixmap(QPixmap::fromImage(*image));
                

                shrinking the jpg down to 600 x 450 or 595 x 446 or 500 x 375 doesn't help

                Documentation says I need to write a const char* to indicate format.....I've tried "JPG" "jpg" "jpeg" and "JPEG".
                nothing works!!!

                How do I make QImage swallow a jpg??

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @Rapidrain said in QImage doesn't take in a JPG:

                QImage* image = new QImage();
                	bool b1 = image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.jpg", "jpeg");
                	if (b1 == true) {
                
                		std::cout << "true " << std::endl;
                	}
                	else {
                                // this guy always appears for *.jpg
                		std::cout << "false " << std::endl;
                	}
                	setPixmap(QPixmap::fromImage(*image));
                

                your image is made with the jpg-codec but you tell QImage to use explicitly jpeg. I'm not 100% sure but I believe the headers are different.

                Try it with the default probe/guess of the image format.

                bool b1 = image->load("D:/Projects/FridgeMagnets3/src/f1.jpg");
                

                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                R 1 Reply Last reply
                3
                • jsulmJ jsulm

                  @Rapidrain Some question:

                  1. How did you install Qt (is it your own build or precompiled binary)?
                  2. Not related to your problem: why do you allocate image on the heap using new operator (QImage image; would be enough)?
                  R Offline
                  R Offline
                  Rapidrain
                  wrote on last edited by
                  #8

                  @jsulm

                  1. How did you install Qt (is it your own build or precompiled binary)?

                  my own build, 64 bit Qt

                  1. on the heap or local .... I am trying everything. As a local it doesn't work...As a new it doesn't work.
                  1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    @Rapidrain said in QImage doesn't take in a JPG:

                    QImage* image = new QImage();
                    	bool b1 = image->load("D:\\Projects\\FridgeMagnets3\\src\\f1.jpg", "jpeg");
                    	if (b1 == true) {
                    
                    		std::cout << "true " << std::endl;
                    	}
                    	else {
                                    // this guy always appears for *.jpg
                    		std::cout << "false " << std::endl;
                    	}
                    	setPixmap(QPixmap::fromImage(*image));
                    

                    your image is made with the jpg-codec but you tell QImage to use explicitly jpeg. I'm not 100% sure but I believe the headers are different.

                    Try it with the default probe/guess of the image format.

                    bool b1 = image->load("D:/Projects/FridgeMagnets3/src/f1.jpg");
                    
                    R Offline
                    R Offline
                    Rapidrain
                    wrote on last edited by
                    #9

                    @J.Hilk I have used "jpg" and "jpeg" and "JPG" and "JPEG" and none of them work

                    As you suggested, I left out the second argument completely and it still doesn't work.

                    I am compiling this with MinGW using Eclipse Neon

                    the Compile statements are :

                    15:15:53 **** Build of configuration Debug for project FridgeMagnets3 ****
                    MinGW32-make -f mf.Debug alld

                    1 create obj/Debug/FridgeMagnets3d.o
                    D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/FridgeMagnets3d.o src/FridgeMagnets3.cpp

                    2a create obj/Debug/MyLabeld.o
                    D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/MyLabeld.o src/MyLabel.cpp

                    2b create src/moc_MyLabeld.cpp
                    D:/Qt64/qt-install/bin/moc.exe -DUNICODE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -D__GNUC__ -DWIN32 -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' src/MyLabel.h -o src/moc_MyLabeld.cpp
                    2c create obj/Debug/moc_MyLabeld.o

                    D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/moc_MyLabeld.o src/moc_MyLabeld.cpp
                    3a create obj/Debug/DragWidgetd.o

                    D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/DragWidgetd.o src/DragWidget.cpp
                    ^
                    3c create obj/Debug/moc_MyLabeld.o
                    D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/moc_DragWidgetd.o src/moc_DragWidgetd.cpp

                    Link objects obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o
                    D:/MinGW/64/bin/g++ -Wl,-subsystem,windows -mthreads -o D:/Projects/FridgeMagnets3/bin/Debug/FridgeMagnets32d.exe obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o -LD:/Qt64/qt-install/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Core -lQt5Gui

                    any libraries missing?

                    jsulmJ 1 Reply Last reply
                    0
                    • R Rapidrain

                      @J.Hilk I have used "jpg" and "jpeg" and "JPG" and "JPEG" and none of them work

                      As you suggested, I left out the second argument completely and it still doesn't work.

                      I am compiling this with MinGW using Eclipse Neon

                      the Compile statements are :

                      15:15:53 **** Build of configuration Debug for project FridgeMagnets3 ****
                      MinGW32-make -f mf.Debug alld

                      1 create obj/Debug/FridgeMagnets3d.o
                      D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/FridgeMagnets3d.o src/FridgeMagnets3.cpp

                      2a create obj/Debug/MyLabeld.o
                      D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/MyLabeld.o src/MyLabel.cpp

                      2b create src/moc_MyLabeld.cpp
                      D:/Qt64/qt-install/bin/moc.exe -DUNICODE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -D__GNUC__ -DWIN32 -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' src/MyLabel.h -o src/moc_MyLabeld.cpp
                      2c create obj/Debug/moc_MyLabeld.o

                      D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/moc_MyLabeld.o src/moc_MyLabeld.cpp
                      3a create obj/Debug/DragWidgetd.o

                      D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/DragWidgetd.o src/DragWidget.cpp
                      ^
                      3c create obj/Debug/moc_MyLabeld.o
                      D:/MinGW/64/bin/g++ -c -g -std=gnu++11 -pipe -fno-keep-inline-dllexport -O0 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I'D:/Qt64/qt-install/include' -I'D:/Qt64/qt-install/include/QtWidgets' -I'D:/Qt64/qt-install/include/QtGui' -I'D:/Qt64/qt-install/include/QtCore' -I'D:/Qt64/qt-install/qtbase/include/QtWidgets' -I'D:/Qt64/qt-install/qtbase/include/QtGui' -I'D:/Qt64/qt-install/qtbase/include/QtCore' -I'D:/Projects/FridgeMagnets3/obj/Debug' -I'D:/Projects/FridgeMagnets3/src' -I'D:/Projects/FridgeMagnets3' -o obj/Debug/moc_DragWidgetd.o src/moc_DragWidgetd.cpp

                      Link objects obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o
                      D:/MinGW/64/bin/g++ -Wl,-subsystem,windows -mthreads -o D:/Projects/FridgeMagnets3/bin/Debug/FridgeMagnets32d.exe obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o -LD:/Qt64/qt-install/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Core -lQt5Gui

                      any libraries missing?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Rapidrain Your own build? That could explain your problem: you probably do not have the JPEG plug-in. Check the content of the plugins/imageformats directory of your Qt set-up.
                      If you compile Qt by yourself you should check the output of the configure command: it will tell your what is going to be built and what not.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      R 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @Rapidrain Your own build? That could explain your problem: you probably do not have the JPEG plug-in. Check the content of the plugins/imageformats directory of your Qt set-up.
                        If you compile Qt by yourself you should check the output of the configure command: it will tell your what is going to be built and what not.

                        R Offline
                        R Offline
                        Rapidrain
                        wrote on last edited by Rapidrain
                        #11

                        @jsulm the imageformats directory does (!) exist in the build. I found it last night. Now I wonder if I must include all of them in my compile and link statements, mention them in some manner.

                        My link command was :
                        g++ -Wl,-subsystem,windows -mthreads -o D:/Projects/FridgeMagnets3/bin/Debug/FridgeMagnets32d.exe obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o -LD:/Qt64/qt-install/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Core -lQt5Gui

                        I copied the two files qjpeg.dll and qjpegd.dll into a directory imageformats and placed it next to the executable.
                        Then I changed the link command to :

                        g++ -Wl,-subsystem,windows -mthreads -o D:/Projects/FridgeMagnets3/bin/Debug/FridgeMagnets32d.exe obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o -LD:/Projects/FridgeMagnets3/imageformats -LD:/Qt64/qt-install/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Core -lQt5Gui

                        Note that I added the imageformats directory as a source of libraries in the link command.

                        It didn't help though.

                        jsulmJ 1 Reply Last reply
                        0
                        • R Rapidrain

                          @jsulm the imageformats directory does (!) exist in the build. I found it last night. Now I wonder if I must include all of them in my compile and link statements, mention them in some manner.

                          My link command was :
                          g++ -Wl,-subsystem,windows -mthreads -o D:/Projects/FridgeMagnets3/bin/Debug/FridgeMagnets32d.exe obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o -LD:/Qt64/qt-install/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Core -lQt5Gui

                          I copied the two files qjpeg.dll and qjpegd.dll into a directory imageformats and placed it next to the executable.
                          Then I changed the link command to :

                          g++ -Wl,-subsystem,windows -mthreads -o D:/Projects/FridgeMagnets3/bin/Debug/FridgeMagnets32d.exe obj/Debug/FridgeMagnets3d.o obj/Debug/MyLabeld.o obj/Debug/moc_MyLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o -LD:/Projects/FridgeMagnets3/imageformats -LD:/Qt64/qt-install/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Core -lQt5Gui

                          Note that I added the imageformats directory as a source of libraries in the link command.

                          It didn't help though.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Rapidrain Sure it exists, but does it contain the JPEG plug-in? It should be named like libqjpeg.so
                          You do not have to add any of them to your compile/link config!
                          When deploying your app later you just need to make sure you deploy all needed plug-ins as well. See http://doc.qt.io/qt-5/linux-deployment.html

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          R 1 Reply Last reply
                          2
                          • jsulmJ jsulm

                            @Rapidrain Sure it exists, but does it contain the JPEG plug-in? It should be named like libqjpeg.so
                            You do not have to add any of them to your compile/link config!
                            When deploying your app later you just need to make sure you deploy all needed plug-ins as well. See http://doc.qt.io/qt-5/linux-deployment.html

                            R Offline
                            R Offline
                            Rapidrain
                            wrote on last edited by
                            #13

                            @jsulm there is qjpeg.dll in the imageformats directory but ....
                            libqjpeg.so is nowhere on my computers.
                            I have used Qt for years and have countless versions here.
                            I have never seed libqjpeg.so

                            jsulmJ 1 Reply Last reply
                            0
                            • R Rapidrain

                              @jsulm there is qjpeg.dll in the imageformats directory but ....
                              libqjpeg.so is nowhere on my computers.
                              I have used Qt for years and have countless versions here.
                              I have never seed libqjpeg.so

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @Rapidrain Sorry forgot that you're on Windows. qjpeg.dll is what you need.
                              Try to start your app with QT_DEBUG_PLUGINS environment variable set to 1 (you can add it in QtCreator Run settings of your project).

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              R 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @Rapidrain Sorry forgot that you're on Windows. qjpeg.dll is what you need.
                                Try to start your app with QT_DEBUG_PLUGINS environment variable set to 1 (you can add it in QtCreator Run settings of your project).

                                R Offline
                                R Offline
                                Rapidrain
                                wrote on last edited by
                                #15

                                @jsulm said in QImage doesn't take in a JPG:

                                QT_DEBUG_PLUGINS

                                I'm not using QtCreator

                                jsulmJ 1 Reply Last reply
                                0
                                • R Rapidrain

                                  @jsulm said in QImage doesn't take in a JPG:

                                  QT_DEBUG_PLUGINS

                                  I'm not using QtCreator

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @Rapidrain When do it wherever you're developing. If you start your app from a terminal:

                                  QT_DEBUG_PLUGINS=1 && ./my_app
                                  

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  R 1 Reply Last reply
                                  0
                                  • jsulmJ jsulm

                                    @Rapidrain When do it wherever you're developing. If you start your app from a terminal:

                                    QT_DEBUG_PLUGINS=1 && ./my_app
                                    
                                    R Offline
                                    R Offline
                                    Rapidrain
                                    wrote on last edited by
                                    #17

                                    @jsulm said in QImage doesn't take in a JPG:

                                    QT_DEBUG_PLUGINS=1 && ./my_app

                                    I tried what you suggested, it doesn't help.

                                    0_1500978497455_Cmd_calling_the_exe.jpg

                                    jsulmJ 1 Reply Last reply
                                    0
                                    • R Rapidrain

                                      @jsulm said in QImage doesn't take in a JPG:

                                      QT_DEBUG_PLUGINS=1 && ./my_app

                                      I tried what you suggested, it doesn't help.

                                      0_1500978497455_Cmd_calling_the_exe.jpg

                                      jsulmJ Offline
                                      jsulmJ Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      @Rapidrain Sorry, again forgot that you're on Windows:

                                      set QT_DEBUG_PLUGINS=1
                                      ./my_app
                                      

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      R 1 Reply Last reply
                                      0
                                      • jsulmJ jsulm

                                        @Rapidrain Sorry, again forgot that you're on Windows:

                                        set QT_DEBUG_PLUGINS=1
                                        ./my_app
                                        
                                        R Offline
                                        R Offline
                                        Rapidrain
                                        wrote on last edited by
                                        #19

                                        @jsulm said in QImage doesn't take in a JPG:

                                        QT_DEBUG_PLUGINS=1

                                        guess what?
                                        It doesn't help.
                                        Can you suggest a chain of options I must add to g++ when compiling and linking this code?

                                        0_1500984817989_Cmd2_call_exe.jpg

                                        jsulmJ 1 Reply Last reply
                                        0
                                        • R Rapidrain

                                          @jsulm said in QImage doesn't take in a JPG:

                                          QT_DEBUG_PLUGINS=1

                                          guess what?
                                          It doesn't help.
                                          Can you suggest a chain of options I must add to g++ when compiling and linking this code?

                                          0_1500984817989_Cmd2_call_exe.jpg

                                          jsulmJ Offline
                                          jsulmJ Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          @Rapidrain said in QImage doesn't take in a JPG:

                                          Can you suggest a chain of options I must add to g++ when compiling and linking this code?

                                          As I said before: there is no need to add any options to compiler/linker. The plug-ins are automatically loaded at runtime when needed. You either have some issues with your JPEG plug-in or with the picture you're trying to display. See http://doc.qt.io/qt-5/debug.html
                                          After setting QT_DEBUG_PLUGINS your app should actually output a lot of text. Do you test a debug build?

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          R 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved