Results 1 to 5 of 5

Thread: [SOLVED]Image color Convert, stumbling upon answer

  1. #1
    Join Date
    Jun 2013
    Posts
    46
    Thanks
    24
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Post [SOLVED]Image color Convert, stumbling upon answer

    [Solved]
    Changed from QLabel to QGraphicsView
    Qt Code:
    1. QGraphicsColorizeEffect *effect;
    2. effect = new QGraphicsColorizeEffect;
    3.  
    4. effect->setColor(QColor(Qt::red));
    To copy to clipboard, switch view to plain text mode 

    Apologies for any inconvenience

    Next time will do my homework better before posting

    Apologies

    Kind Regards


    -----------------------------------------------------------------------------------------------------------------------------


    This is a similar thread to others, but not the same!

    I was initially trying to convert an image to gray scale
    when my code instead of converting everything to grayscale
    took a black & white image kept the black as is & converted the the white to dark blue----> fantastic

    Thats actually what i needed, the thing is how do I change what colour should the white be converted to?
    because technically my code does not specify blue!


    Qt Code:
    1. image1 = image1.convertToFormat(QImage::Format_RGB32);
    2.  
    3. QRgb color;
    4. for (int i=0; f1<image1.width(); i++) {
    5. for (int j=0; j<image1.height(); j++) {
    6. color = image1.pixel(i, j);
    7. image1.setPixel(i, j, QColor((qRed(color) + qGreen(color) + qBlue(color))/3).rgb());
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Whenever i put the above code i my program it converts all white to blue

    Initially i wanted grayscale but im more than happy with this result
    though I want to choose which color

    Ideas please


    Kind Regards
    Last edited by 2lights; 27th August 2013 at 08:13. Reason: updated contents

  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: Image color Convert, stumbling upon answer

    How is the code you posted related to what you have written in the description?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2013
    Posts
    4
    Qt products
    Qt5 Qt/Embedded

    Default Re: Image color Convert, stumbling upon answer

    I just started with Qt, but shouldn't line 4 be:
    Qt Code:
    1. for (int i=0; i < image1.width(); i++)
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jun 2013
    Posts
    46
    Thanks
    24
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Image color Convert, stumbling upon answer

    [Solved]
    Changed from QLabel to QGraphicsView

    Qt Code:
    1. QGraphicsColorizeEffect *effect;
    2. effect = new QGraphicsColorizeEffect;
    3.  
    4. effect->setColor(QColor(Qt::red));
    To copy to clipboard, switch view to plain text mode 

    Apologies for any inconvenience
    Next time will do my homework better before posting

    Kind Regards

  5. #5
    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: Image color Convert, stumbling upon answer

    You can apply the colorize effect to the label as well.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    2lights (27th August 2013)

Similar Threads

  1. Replies: 2
    Last Post: 30th December 2011, 05:44
  2. convert 16 bit raw data to 24bit bitmap image
    By bibhukalyana in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2011, 18:58
  3. need to convert Raw Image Data direct to QPixmap
    By syclopse in forum Qt Programming
    Replies: 6
    Last Post: 18th July 2011, 13:57
  4. How to convert JPEG image into binary data?
    By Gokulnathvc in forum Newbie
    Replies: 1
    Last Post: 7th June 2011, 08:43
  5. Replies: 3
    Last Post: 6th March 2009, 15:11

Tags for this Thread

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.