Ive done a bunch of searches, and gone through lots of tutorials on memblocks and images, and still I am having a tricky issue.
I want to retrieve the RGB value of a point on an image, that point being function defined. I know of the native point command, but Ive been told that its slow and standoffish...
The problem Im having is that I cannot for the life of me figure out the coordinate's conversion to a memory location within the memblock. Here is what I got.
ink rgb(255,0,0),0
box 0,0,100,100
ink rgb(0,255,0),0
box 50,0,100,100
get image 1,0,0,100,100
do
sprite 1,0,0,1
if mouseclick() then
col = getColorPoint(1,mouseX(),mouseY())
text 100,400,str$(col)
text 100,420,str$(rgbr(col))
sync
LOOP
Function getColorPoint(Image,x,y)
width = image width(image)
height = image height(image)
color as dword
memNum = 1
if memblock exist(memNum) then delete memblock memNum
make memblock from image memNum,image
position = (y*Width+x)*4+12
if position => 0 AND position < memSize
redValue = memblock byte(memNum,position)
greenValue = memblock byte(memNum,position+1)
blueValue = memblock byte(memNum,position+2)
endif
color = rgb(redValue,greenValue,blueValue)
delete memblock memNum
Endfunction color
Help would be awesome.