Announcement

Collapse
No announcement yet.

graphic control pixel color question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • graphic control pixel color question

    the %rgb_whitesmoke color is used in a graphic control. The actual value is &HF5F5F5, but when I read the pixel value back with GRAPHIC GET PIXEL it is &HF7F7F7. I think I am missing something, possibly brain cells...

    Code:
    #compile exe
    #dim all
    %IDD_DIALOG1     =  101
    %IDC_GRAPHIC1    = 1001
    '------------------------------------------
    function getxright (hd as dword) as long
        local p2 as pointapi
        local i, yy, l as long
        local s as string ' debug
        
        graphic get client to p2.x, p2.y
        ' start at the RH edge and move inwards until the rgb_whitesmoke chart area is reached
        ' This is the RH end of the plotbaseline.
        '? str$(p2.x) + str$(p2.y)
        yy = p2.y -20
        i = p2.x
        l = %rgb_whitesmoke
        s = "%rgb_whitesmoke =" + hex$(l) + $crlf
        do
            graphic get pixel (i, yy) to l
            graphic set pixel (i, yy), %red' debug
            if l = %rgb_whitesmoke then
                function = i
                exit function
            end if
            s = s + " " + hex$(l) ' debug
            decr i
        loop while i > 0
        graphic redraw ' debug
        ? s 'debug
    end function
    '---------------------------------------
    callback function ShowDIALOG1Proc()
        local x, y, l as long
        select case as long cbmsg
            case %wm_initdialog
                graphic attach cb.hndl, %idc_graphic1
                graphic get client to x, y
                graphic box (10, 10) - (x-10, y-10), 0, %rgb_whitesmoke, %rgb_whitesmoke, 0
                l = getxright( cb.hndl)
        end select
    end function
    '---------------------------------------
    function ShowDIALOG1(byval hParent as dword) as long
        local lRslt as long
        local hDlg  as dword
    
        dialog new hParent, "graphic pixel color problem", 242, 122, 201, 144, %ws_popup or %ws_border or %ws_dlgframe or %ws_sysmenu _
            or %ws_clipsiblings or %ws_visible or %ds_modalframe or %ds_3dlook or %ds_nofailcreate or %ds_setfont, _
            %ws_ex_controlparent or %ws_ex_left or %ws_ex_ltrreading or %ws_ex_rightscrollbar, to hDlg
        control add graphic, hDlg, %IDC_GRAPHIC1, "", 8, 10, 184, 100
        dialog show modal hDlg, call ShowDIALOG1Proc to lRslt
        function = lRslt
    end function
    '---------------------------------------
    function pbmain()
        ShowDIALOG1 %hwnd_desktop
    end function

  • #2
    Works as requested here, Chris. I added a Textbox and it kicks out at F5F5F5:
    Code:
      
    'PBWIN 9.02 - WinApi 05/2008 - XP Pro 
    
    #Compile Exe
    #Dim All
    %IDD_DIALOG1     =  101
    %IDC_GRAPHIC1    = 1001
    %Show_tb = 1003
        Global hDlg  As Dword
    '------------------------------------------
    Function getxright (hd As Dword) As Long
        Local p2 As pointapi
        Local i, yy, l As Long
        Local s As String ' debug
        
        Graphic Get Client To p2.x, p2.y
        ' start at the RH edge and move inwards until the rgb_whitesmoke chart area is reached
        ' This is the RH end of the plotbaseline.
        '? str$(p2.x) + str$(p2.y)
        yy = p2.y -20
        i = p2.x
        l = %rgb_whitesmoke
        s = "%rgb_whitesmoke =" + Hex$(l) + $CrLf
        Do
            Graphic Get Pixel (i, yy) To l
            Graphic Set Pixel (i, yy), %Red' debug
            If l = %rgb_whitesmoke Then
                Function = i
            Control Set Text hdlg, %Show_tb, Using$("i #   l #, ", i, l) & Hex$(l)
                Exit Function
            End If       
            Control Set Text hdlg, %Show_tb, Using$("i #   l #, ", i, l) & Hex$(l)
            s = s + " " + Hex$(l) ' debug
            Decr i
        Loop While i > 0
        Graphic ReDraw ' debug
        ? s 'debug
    End Function
    '---------------------------------------
    CallBack Function ShowDIALOG1Proc()
        Local x, y, l As Long
        Select Case As Long CbMsg
            Case %wm_initdialog
                Graphic Attach CB.Hndl, %idc_graphic1
                Graphic Get Client To x, y
                Graphic Box (10, 10) - (x-10, y-10), 0, %rgb_whitesmoke, %rgb_whitesmoke, 0
                l = getxright( CB.Hndl)
        End Select
    End Function
    '---------------------------------------
    Function ShowDIALOG1(ByVal hParent As Dword) As Long
        Local lRslt As Long
        Dialog New hParent, "graphic pixel color problem", 242, 122, 201, 144, %ws_popup Or %ws_border Or %ws_dlgframe Or %ws_sysmenu _
            Or %ws_clipsiblings Or %ws_visible Or %ds_modalframe Or %ds_3dlook Or %ds_nofailcreate Or %ds_setfont, _
            %ws_ex_controlparent Or %ws_ex_left Or %ws_ex_ltrreading Or %ws_ex_rightscrollbar, To hDlg
        Control Add Graphic, hDlg, %IDC_GRAPHIC1, "", 8, 10, 184, 100
        Control Add TextBox, hDlg, %Show_tb, " tb", 8, 110, 100, 10
        Dialog Show Modal hDlg, Call ShowDIALOG1Proc To lRslt
        Function = lRslt
    End Function
    '---------------------------------------
    Function PBMain()
        ShowDIALOG1 %hwnd_desktop
    End Function
    ==========================================
    An uneducated man has one great advantage
    over an educated man.
    He does not know
    what is not possible.
    Swede
    ==========================================
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

    Comment


    • #3
      Thanks for trying it Gösta!

      I don't know why I did not suspect the video RAM - except that I have not had video RAM fail on me since the days of 16x64! Just re-tested with some other colors and it fails in a similar way.

      Come to think of it I have removed one screen and the Nvidia controller and had not noticed the error before doing that. Currently running the built-in Intel controller - shall re-install the Nvidia.

      **** later - Nvidia will not drive the old Samsung display. So it's time for a new screen. ****.
      Chris Holbrook
      Member
      Last edited by Chris Holbrook; 11 Oct 2009, 04:35 AM.

      Comment

      Working...
      X