×

Discussion Board

Results 1 to 6 of 6

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    21

    Find out the specific pixel and change its color?(C++)

    I want to find out all pixels which are white color in a bitmap,and change their color to 0x00ff00ff.I use these codes as below,but I still cant change their color.I dont konw why.
    TUint32* piaddress = iBitmaptest->DataAddress();
    TSize tsize = iBitmaptest->SizeInPixels();
    TBitmapUtil bitmaptestutil(iBitmaptest);
    bitmaptestutil.Begin(TPoint(0,0));
    TInt xPos,yPos;
    for(yPos=0;yPos<tsize.iHeight;yPos++)
    {
    bitmaptestutil.SetPos(TPoint(0,yPos));
    for(xPos=0;xPos<tsize.iWidth;xPos++)
    {
    if(0x00ffffff==bitmaptestutil.GetPixel())
    {
    bitmaptestutil.SetPixel(0x00ff00ff); bitmaptestutil.IncXPos();

    }
    bitmaptestutil.IncXPos();
    }
    }
    bitmaptestutil.End();

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    at least you position stays all the time in the first pixel in the line:

    bitmaptestutil.SetPos(TPoint(0,yPos));

    yucca

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    21
    bitmaptestutil.IncXPos();
    every time after inner loop:
    for(xPos=0;xPos<tsize.iWidth;xPos++)
    {
    }
    my position stays in the first pixel in the line.but in the inner loop
    i use "bitmaptestutil.IncXPos();"so the position move from the first
    pixel to the end in the line.

    otherwise,do you know how to get the pixel color and change the color,you can use any solution.
    Thank you

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    Hi

    my mistake, didn't notice that line... anyway I used very similar code in one of my apps and it worked as it should. Basically I was using the Set pos for each pixel, but I quess the inc should work as well.

    yucca

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    21

    HI

    another question is that I dont know what value the GetPixel() return.what a white pixel should return?I use GetPixel () to get a
    white bitmap pixel.but it return value 3137.

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    Dunno really, but try the constant KRgbWhite either by it self of with TRgb.

    yucca

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •