Results 1 to 7 of 7

Thread: convert to immagine in RgB and manipulate

  1. #1

    Default convert to immagine in RgB and manipulate

    Hi
    i have to convert immagine jpg into Rgb and convert in grey.

    Can you suggest?

  2. #2

    Default Re: convert to immagine in RgB and manipulate

    i can try with for but i dont understand the functions to use.

    for example:

    QPixmap pix(":/pathFile/NameFile.jpg"); //

    //


    for (int ii = 0; ii < pix.height(); ii++) {

    for (int jj = 0; jj < pix.width(); jj++) {

    // qGray(1,1,1);

    }
    }


    Added after 1 41 minutes:


    QImage immagine(":/PATH/IMMAGINE.jpg");
    QRgb color;


    for (int ii = 0; ii < immagine.height(); ii++) {

    for (int jj = 0; jj < immagine.width(); jj++) {

    color = immagine.pixel(ii,jj);
    immagine.setPixel(ii,jj,QColor((qRed(color)*0.3) + qGreen(color)*0.59 + qBlue(color)*0.11).rgb());





    }
    Last edited by montanaro; 19th July 2018 at 11:10.

  3. #3

    Default Re: convert to immagine in RgB and manipulate

    It returned:


    QImage:ixel: coordinate (199,822) out of range

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: convert to immagine in RgB and manipulate

    Quote Originally Posted by montanaro View Post
    It returned:


    QImage:ixel: coordinate (199,822) out of range
    That's because the parameters for immagine.pixel() and setPixel() are in the wrong order.

    Ginsengelf

  5. #5

    Default Re: convert to immagine in RgB and manipulate

    Quote Originally Posted by Ginsengelf View Post
    That's because the parameters for immagine.pixel() and setPixel() are in the wrong order.

    Ginsengelf
    yes. thank you.
    i corrected.
    but the code dont transform immage yet

  6. #6

    Default Re: convert to immagine in RgB and manipulate

    i solvede into Windows:

    "
    QSize sizeImage = immagine.size();
    int width = sizeImage.width(), height = sizeImage.height();

    QRgb color;



    for (int f1=0; f1<width; f1++) {
    for (int f2=0; f2<height; f2++) {
    color = immagine.pixel(f1, f2);


    // color= immagine.pixel(j,i);
    // image.setPixel(f1, f2, QColor((qRed(color) + qGreen(color) + qBlue(color))/3).rgb());



    int grigio= qGray(color);


    immagine.setPixel(f1,f2, qRgb(grigio, grigio, grigio));
    }
    }"



    but when i use qt on linux virtual machine, it dont run

    virtual machine says: " conncection refused"


    you can suggest ?

  7. #7

    Default Re: convert to immagine in RgB and manipulate

    i changed ip in qt option and now it runs

    but now my duty is porting in QML

    how i can? :O

Similar Threads

  1. Manipulate QGraphicsTextItems on a QGraphicsScene
    By airglide in forum Qt Programming
    Replies: 4
    Last Post: 29th July 2012, 00:38
  2. how to manipulate a very large data using QT?
    By aurora in forum Qt Programming
    Replies: 10
    Last Post: 25th May 2012, 18:37
  3. PyQt: How to manipulate QFileDialog
    By xaverxn in forum Newbie
    Replies: 1
    Last Post: 28th October 2010, 21:58
  4. How to manipulate a thread
    By avis_phoenix in forum Newbie
    Replies: 1
    Last Post: 19th August 2008, 00:34
  5. [java] manipulate a string
    By mickey in forum General Programming
    Replies: 5
    Last Post: 10th July 2008, 21:22

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.