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. How to correct the Image?
Forum Updated to NodeBB v4.3 + New Features

How to correct the Image?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.3k Views 1 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
    Rohith
    wrote on last edited by Rohith
    #1

    Hi i am trying to convert an image in to BMP and then i want to print it, but when i am converting the image to BMP using QImage the image seems as follows

    how can i upload picture

    Please help me to convert the Image to a good quality

    Thanks in advance

    kshegunovK 1 Reply Last reply
    0
    • khakhilK Offline
      khakhilK Offline
      khakhil
      wrote on last edited by
      #2

      hey
      i am getting your problem completely but related your issue i found something here.
      https://www.kdab.com/qt-on-android-how-to-convert-qt-images-to-android-images-and-vice-versa/

      http://stackoverflow.com/questions/31137830/display-image-from-raw-bitmap-file-to-bmp-file

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        Could you provide an example image and how it gets out using your method?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • R Rohith

          Hi i am trying to convert an image in to BMP and then i want to print it, but when i am converting the image to BMP using QImage the image seems as follows

          how can i upload picture

          Please help me to convert the Image to a good quality

          Thanks in advance

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Rohith
          The forum's image upload is broken, please use an external site (e.g. postimage.org).

          Read and abide by the Qt Code of Conduct

          R 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @Rohith
            The forum's image upload is broken, please use an external site (e.g. postimage.org).

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

            @kshegunov

            Here is the Link of Image Please Go through It

            https://s12.postimg.org/npwtmfvml/finalimage.jpg

            kshegunovK 1 Reply Last reply
            0
            • R Rohith

              @kshegunov

              Here is the Link of Image Please Go through It

              https://s12.postimg.org/npwtmfvml/finalimage.jpg

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              @Rohith
              It looks strange. How do you make the conversion? And what did you mean by "print', do you want to send the image to a printer, or only to show it on the screen?

              Read and abide by the Qt Code of Conduct

              R 1 Reply Last reply
              0
              • kshegunovK kshegunov

                @Rohith
                It looks strange. How do you make the conversion? And what did you mean by "print', do you want to send the image to a printer, or only to show it on the screen?

                R Offline
                R Offline
                Rohith
                wrote on last edited by Rohith
                #7

                @kshegunov

                I want to send the image to the printer for printing

                here is code

                QImage img("1.jpg");
                                QImage img1 = img.scaled(QSize(384,500), Qt::IgnoreAspectRatio);
                        QBitmap *prnbmp1 = new QBitmap(QBitmap::fromImage((const QImage)img1,Qt::MonoOnly));
                           prnbmp1->save("finalimage.bmp","BMP",-1);
                       
                        QImage img2("finalimage.bmp" );
                        img2.save("finalimage.bmp");
                        QFile file1("finalimage.bmp");
                        qDebug()<<"size of img in bytes"<<file1.size();
                
                

                after converting to Bmp i am sending to printer by converting the BMP to HEX

                here is the Link for Original Image

                https://s10.postimg.org/lj1v7ddy1/image.jpg

                Thanks in advance

                kshegunovK 1 Reply Last reply
                0
                • VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by VRonin
                  #8

                  form http://doc.qt.io/qt-5/qimage.html

                  Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. Finally, the QPicture class is a paint device that records and replays QPainter commands.

                  QImage img("1.jpg");
                  QImage img1 = img.scaled(QSize(384,500), Qt::IgnoreAspectRatio);
                  img1.convertToFormat(QImage::Format_Mono); //Converts to black and white but original image is already B/W so I'm not sure it's necessary
                  img1.save("finalimage.bmp","BMP");
                  

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  1 Reply Last reply
                  1
                  • R Rohith

                    @kshegunov

                    I want to send the image to the printer for printing

                    here is code

                    QImage img("1.jpg");
                                    QImage img1 = img.scaled(QSize(384,500), Qt::IgnoreAspectRatio);
                            QBitmap *prnbmp1 = new QBitmap(QBitmap::fromImage((const QImage)img1,Qt::MonoOnly));
                               prnbmp1->save("finalimage.bmp","BMP",-1);
                           
                            QImage img2("finalimage.bmp" );
                            img2.save("finalimage.bmp");
                            QFile file1("finalimage.bmp");
                            qDebug()<<"size of img in bytes"<<file1.size();
                    
                    

                    after converting to Bmp i am sending to printer by converting the BMP to HEX

                    here is the Link for Original Image

                    https://s10.postimg.org/lj1v7ddy1/image.jpg

                    Thanks in advance

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #9

                    You don't need all this. Just write the image to the file with the appropriate format. E.g:

                    QImage img = QImage("1.jpg").scaled(QSize(384,500), Qt::IgnoreAspectRatio);
                    if (!img.save("finalimage.bmp", "BMP"))
                        ; //< Couldn't save the image, handle the error
                    

                    Look here for the supported formats.

                    Kind regards.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    1

                    • Login

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