From.GetPixel on the Device

Discussion in 'Questions (Windows Mobile)' started by alfcen, Jul 11, 2007.

  1. alfcen

    alfcen Well-Known Member Licensed User

    Is anyone aware of a problem with From.GetPixel() on the device?
    The following routine works great on the dektop, however on the PPC all circles are drawn in white. The o/s of the PPC is PPC2003 though.

    If pos > 3 And pos < 3.3 Then
    If frmGalilean.GetPixel(px,py)=cYellow Then
    frmGalilean.Circle(px,py,1,cYellow ,F)
    else
    frmGalilean.Circle(px,py,1,cWhite,F)
    end if
    Else
    frmGalilean.Circle(px,py,1,cWhite,F)
    End If

    By the way, could a Form.SetPixel command be added to to future version?
    Thanks a lot!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    As the device supports only 65k colors some values may change a little bit.
    Add a msgbox before your code:
    Msgbox("GetPixel color: " & frmGalilean.GetPixel(px,py) & crlf & "cYellow: " & cYellow & crlf & "cWhite: " & cWhite)
    What values do you get? (note that cWhite and cYellow are constants)
     
  3. alfcen

    alfcen Well-Known Member Licensed User

    Thank you very much, Erel.
    Yep, the device provides 'only' 65k colors.
    I will check them on the device as you suggested.
    Cheers
    Robert
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    One way to solve this problem is to save the color of a known "yellow" colored pixel and then compare the GetPixel with this color.
     
  5. alfcen

    alfcen Well-Known Member Licensed User

    Hi Erel,
    Your second approach did the trick.
    This works for both, desktop and PPC:

    If pos > 3 And pos < 3.3 Then
    If frmGalilean.GetPixel(px,py)=frmGalilean.GetPixel(x0,y0) Then
    frmGalilean.Circle(px,py,1,cYellow ,F)
    else
    frmGalilean.Circle(px,py,1,cWhite,F)
    end if
    Else
    frmGalilean.Circle(px,py,1,cWhite,F)
    End If

    Obviously, on the PPC, I must not use the color of a coordinate exactly onto which the circle is to be drawn. Don't ask me why :)

    Anyway, thanks so much for your prompt attention.

    Cheers
    Robert
     
Loading...