Sure! I've included some sample sourcecode below.
There's enough there to get you started ;)
Cheers,
Roy
;*** colorList - R Ferriby
Type cnode
Field cnode.cnode[256]
Field count%
End Type
Global mpopRed%,mpopGreen%,mpopBlue%
Global lpopRed%,lpopGreen%,lpopBlue%
colorList.cnode=New cnode
;*** test 8 colors of which 5 should be unique
AddColorToList(colorList,255,0,0)
AddColorToList(colorList,0,255,0)
AddColorToList(colorList,0,0,255)
AddColorToList(colorList,0,0,0)
AddColorToList(colorList,255,255,255)
AddColorToList(colorList,0,255,0)
AddColorToList(colorList,0,255,0)
AddColorToList(colorList,0,255,0)
totalcolors%=TotalColorCount(colorList)
Print "totalcolors= "+totalcolors
uniquecolors%=UniqueColorCount(colorList)
Print "uniquecolors= "+uniquecolors
mpopcolor%=MostPopularColor(colorList)
Print "most popular color= "+mpopRed+", "+mpopGreen+", "+mpopBlue+" count="+mpopcolor
lpopcolor%=LeastPopularColor(colorList)
Print "least popular color= "+lpopRed+", "+lpopGreen+", "+lpopBlue+" count="+lpopcolor
WaitKey
End
Function AddColorToList(clist.cnode,r%,g%,b%)
;*** first RED
If clist\cnode[r]=Null
clist\cnode[r]=New cnode
EndIf
clist\cnode[r]\count=clist\cnode[r]\count+1
;*** next GREEN
If clist\cnode[r]\cnode[g]=Null
clist\cnode[r]\cnode[g]=New cnode
EndIf
clist\cnode[r]\cnode[g]\count=clist\cnode[r]\cnode[g]\count+1
;*** last BLUE
If clist\cnode[r]\cnode[g]\cnode[b]=Null
clist\cnode[r]\cnode[g]\cnode[b]=New cnode
EndIf
clist\cnode[r]\cnode[g]\cnode[b]\count=clist\cnode[r]\cnode[g]\cnode[b]\count+1
End Function
Function TotalColorCount%(clist.cnode)
Local i%,c%
For i=0 To 255
If clist\cnode[i]<>Null
c=c+clist\cnode[i]\count
EndIf
Next
Return c
End Function
Function UniqueColorCount%(clist.cnode)
Local r%,g%,b%,c%
c=0
For r=0 To 255
If clist\cnode[r]<>Null
Local gnode.cnode=clist\cnode[r]
For g=0 To 255
If gnode\cnode[g]<>Null
Local bnode.cnode=gnode\cnode[g]
For b=0 To 255
If bnode\cnode[b]<>Null
c=c+1
EndIf
Next
EndIf
Next
EndIf
Next
Return c
End Function
Function MostPopularColor%(clist.cnode)
Local r%,g%,b%,c%
Local popular.cnode=Null
c=0
For r=0 To 255
If clist\cnode[r]<>Null
If clist\cnode[r]\count>c
popular=clist\cnode[r]
c=popular\count
mpopRed=r
EndIf
EndIf
Next
If popular<>Null
clist=popular
c=0
For g=0 To 255
If clist\cnode[g]<>Null
If clist\cnode[g]\count>c
popular=clist\cnode[g]
c=popular\count
mpopGreen=g
EndIf
EndIf
Next
If popular<>Null
clist=popular
c=0
For b=0 To 255
If clist\cnode[b]<>Null
If clist\cnode[b]\count>c
popular=clist\cnode[b]
c=popular\count
mpopBlue=b
EndIf
EndIf
Next
EndIf
EndIf
Return c
End Function
Function LeastPopularColor%(clist.cnode)
Local r%,g%,b%,c%
Local popular.cnode=Null
c=$7fffffff
For r=0 To 255
If clist\cnode[r]<>Null
If clist\cnode[r]\count<c
popular=clist\cnode[r]
c=popular\count
lpopRed=r
EndIf
EndIf
Next
If popular<>Null
clist=popular
c=$7fffffff
For g=0 To 255
If clist\cnode[g]<>Null
If clist\cnode[g]\count<c
popular=clist\cnode[g]
c=popular\count
lpopGreen=g
EndIf
EndIf
Next
If popular<>Null
clist=popular
c=$7fffffff
For b=0 To 255
If clist\cnode[b]<>Null
If clist\cnode[b]\count<c
popular=clist\cnode[b]
c=popular\count
lpopBlue=b
EndIf
EndIf
Next
EndIf
EndIf
Return c
End Function