Results 1 to 8 of 8

Thread: how to apply a color mask a QImage?

  1. #1
    Join Date
    Jul 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question how to apply a color mask a QImage?

    hello

    I have a gray image in Qimage like this:

    imgGray.jpg


    and I need to apply a mask to change the color but without changing the image. For example...


    imgColor.jpg


    Any idea how I can do this????


    thanks

  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: how to apply a color mask a QImage?

    How is the "mask" defined? Is it an image? How exactly do you want to "mask" the image?
    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
    Jul 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to apply a color mask a QImage?

    I have an image in gray and I want you to see color.

    How I can do that????

    that is, change the pixels of the image grayscale to RGB

  4. #4
    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: how to apply a color mask a QImage?

    There is a number of algorithms you can use and depending which one you choose, you'll get a different result.
    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.


  5. #5
    Join Date
    Jul 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to apply a color mask a QImage?

    can you give me an example of one of these algorithms?

  6. #6
    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: how to apply a color mask a QImage?

    Launch Gimp or Photoshop and take a look at the different layer compositing modes.
    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.


  7. #7
    Join Date
    Jul 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to apply a color mask a QImage?

    I may not explain well, my English is terrible.

    anyway I solved the problem by doing this:



    QVector<QRgb>color; //vector must be completed

    QImage img1("image.jpg");
    QImage img2(img.width(), img.height(), QImage::Format_RGB32);
    int n;


    for(int x=0; x<img.width();x++)
    {
    for(int y=0; y<img.height();y++)
    {
    n=img1.pixel(x,y);
    img2.setPixel( x, y, color[n] );
    }
    }

    thanks

  8. #8
    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: how to apply a color mask a QImage?

    Doesn't it simply copy one image into the other?
    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.


Similar Threads

  1. how to apply realtime color mapping
    By hakiim35 in forum Qwt
    Replies: 1
    Last Post: 10th May 2011, 06:37
  2. Replies: 0
    Last Post: 25th August 2010, 17:39
  3. How to make a mask with QImage?
    By MeteorAndSusan in forum Qt Programming
    Replies: 6
    Last Post: 10th August 2010, 11:06
  4. How it create a true alpha mask from a QImage?
    By nokkie in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2010, 21:07
  5. Draw an 1-bit mask in color?
    By stephenju in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2010, 15:51

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.