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. Why this program doesn't work?

Why this program doesn't work?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 2.4k 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.
  • H Offline
    H Offline
    hor_313
    wrote on last edited by
    #1

    Hi

    This code runs with rgb colors but when i change it to cmyk , it doesn't work . why?

    @ QImage image=QImage("/home/mohammad/1.jpg").scaled(ui->spinBox->value(),ui->spinBox_2->value());
    int i=0 ;int j =0;

    for(j=0 ; j<image.width();j++)
    { for(i=0;i<image.height();i++)
        {
            QColor color=QColor::fromCmyk(image.pixel(i,j));
    
    ui->plainTextEdit->appendPlainText(QString("cyan is : ") + QString::number(color.cyan())
                                       + QString("magenta is: ") + QString::number(color.magenta())
                                       + QString("yellow is:") + QString::number(color.yellow())
                                       + QString("black is") +QString::number(color.black()));
    

    }
    }@

    this is the error : no matching function for call to "QColor::fromCmyk(Qrgb);

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Why would you expect that a method called "fromCymk" will accept a RGB value? Just looking at the name I would expect that method to require a CYMK value.

      Try "fromRgb" to turn the Rgb value into a QColor.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hor_313
        wrote on last edited by
        #3

        [quote author="Tobias Hunger" date="1367692122"]Why would you expect that a method called "fromCymk" will accept a RGB value? Just looking at the name I would expect that method to require a CYMK value.

        Try "fromRgb" to turn the Rgb value into a QColor.[/quote]

        cause I want to rich cmyk values of an image!
        Is it possible? how?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You have to do a color space conversion from RGB to CMYK, QColor has functions for that

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hor_313
            wrote on last edited by
            #5

            I solved it by adding toCmyk() function after this line :

            @QColor color=QColor::fromRgb(image.pixel(i,j)).toCmyk();@

            and so changing fromCmyk to fromRgb

            and the program is working , but i am not sure the returns value are true ?!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What do you mean by true ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • K Offline
                K Offline
                KA51O
                wrote on last edited by
                #7

                i would assume he meant true = correct (not true as a boolean value).

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I would in the first place but there is also the notion of "true color", that's why I asked

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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