loading an image in bos taurus to scan get/set pixel data

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

loading an image in bos taurus to scan get/set pixel data

Post by bluebird »

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

Post Reply