Results 1 to 5 of 5

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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

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.