[Qt-interest] How to change the color of QImage Query

trinathpujari trinathpujari at tataelxsi.co.in
Fri Apr 30 10:43:11 CEST 2010


  Hi All,


  *The QImage background color is purple and text color is black. If I
  select that image then the backgroundcolor has to be changed to black
  and foreground color to become purple color. *


  *    I tried using checking each pixel value as if its black then i
  set purple and vice versa...But in such case text becoming distorted
  (here purple background is example that can be any color)....*

Mine code is like:
     for ( xcount = startx; xcount < endx; xcount++)
        {
            for ( icount=starty; icount<(endy); icount++ )
            {
            if(QColor((image1->pixel(QPoint(xcount,icount))) == bcolor)
             {
                   image1->setPixel(QPoint(xcount,icount),fcolor);
             }
            else if(QColor(image1->pixel(QPoint(xcount,icount))) == fcolor)
                {
                    image1->setPixel(QPoint(xcount,icount),bcolor);
                }
            else
                {
                                // printf("None of the color selected\n");
                }
            }
    }
     Here image1 is big QImage... I am updating some part here and 
drawing this image later. I am changing some part of image here and 
drawing later.


Can anybody tell what API can i use for the above implementation to work.

Thanks in Advance.........

Regards
Trinath









More information about the Qt-interest-old mailing list