HMG Tutorials & Tips

Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
  1. Dear Mentors

    Once again I need to request advice

    I want to read an image into a window and use the BT set/get functions to count how many of the image colors
    are white (for example). When I try to use the code below, the result is zero because the scan checks the original
    window and not the image loaded into it.

    How can I scan the 650 X 500 pixel image that I loaded instead of the containing window itself?.

    Below is the scanning code. I called the window Imagemap
    // add an array entry into aMaoOfPixels for each pixel, true if color is white, false otherwise
    // Uses function IsArrayEqTo(Array1,array2) to check if 2 arrays are equal :?: Also, Is there a better way to do this array check?

    Local i,j,aColor:={0,0,0},lIswhite,nWhite:=0
    For i:=1 TO 500
    for j:=1 to 650

    aColor:= BT_DrawGetPixel (hDC, i, j) // hDC := BT_CreateDC ("ImageMap", BT_HDC_WINDOW , @BTstruct)
    lIsWhite:=IsArrayEqTo(aColor,WHITE)
    aadd(aMapOfPixels,lIsWhite)
    If lIsWhite
    nWhite++
    EndIf
    nIndex++
    next j
    orbitalmap.ThisPoint.Value:=str(i,7)

    next i

    *******************************************
    Function IsArrayEqTo(array1,array2)
    *******************************************
    Local i:=1, lIsEqual:=.F., n
    n:=array1[1]
    if n!=255
    n++
    endif

    If len(array1)!=len(array2)
    return lIsEqual
    Else
    lIsEqual:=.T.
    Do While i<len(array1) .AND. lIsEqual
    lIsEqual:= array1=array2
    i++
    EndDo
    EndIf
    Return lIsEqual

    Statistics: Posted by bluebird — Tue Jan 09, 2018 8:47 pm


  2. you can evaluate it, eq
    x:=100;
    or you can call function
    x:=SomeFunction(...)

    Statistics: Posted by mol — Mon Jan 08, 2018 6:28 am


  3. Dear Mentors

    I would like to know if I can change the value of a variable after a breakpoint stop.
    Seems that I read that you can modify a variable in the Debug doc but how?

    BB

    Statistics: Posted by bluebird — Mon Jan 08, 2018 6:06 am


  4. @ Serge: I didn't expect there to be any handbook, but maybe some explanation like the other Harbour or HMG Commands ;)
    @ All: thanks all for your input! Not only is learning C hard to do, it's not simple either to get it running with HMG. ;)

    Statistics: Posted by Clip2Mania — Wed Dec 06, 2017 6:57 am


  5. See the header file hbapi.h

    Statistics: Posted by srvet_claudio — Tue Dec 05, 2017 4:15 pm