If the target object doesn't need rotation, then you can get a reasonable approximation as follows.
openscreen 1024,768,32,1
loadfximage "E:\Downloads\ground.png",10
spr=getfreesprite()
CreateSprite Spr
PositionSprite Spr,0,600
SpriteImage Spr,10
SpriteCollisionMode Spr,1
; Init the Rays Starting Point
RayX1=300
RayY1=300
Do
Cls RGB(0,0,0)
RayX2=MouseX()
RayY2=MouseY()
DrawAllSprites
If RayHitSprite(RayX1,RayY1,rayX2,rayY2,Spr)=true
ThisImage=getSpriteImage(Spr)
ImageXpos=GetSpritex(Spr)
ImageYpos=GetSpritey(Spr)
Collision,impactx#,impacty#=Plot_Ray_Over_image(Rayx1,Rayy1,Rayx2,Rayy2,ThisImage,ImageXpos,ImageYpos)
if Collision
rayx2=impactx#
rayy2=impacty#
Circle Rayx2,Rayy2,5,false
endif
; RayX2=GetIntersectX#(0)
; RayY2=GetIntersectY#(0)
EndIf
Line RayX1,RayY1,RayX2,RayY2
Sync
Loop
Function Plot_Ray_Over_image(Rayx1#,Rayy1#,Rayx2#,Rayy2#,ThisImage,ImageXpos,ImageYpos)
width =getimagewidth(Thisimage)
height =getimageheight(Thisimage)
Collision=False
Result=LineIntersectRect(Rayx1#,Rayy1#,Rayx2#,Rayy2#,ImageXpos,ImageYpos,ImageXpos+Width,ImageYpos+height)
if result>-1
if Result=1
Rayx1#=GetIntersectX#(0)
Rayy1#=GetIntersectY#(0)
Rayx2#=GetIntersectX#(1)
Rayy2#=GetIntersectY#(1)
endif
;linec Rayx1#,Rayy1#,Rayx2#,Rayy2#,255
dist#=getdistance2d(Rayx1#,Rayy1#,Rayx2#,Rayy2#)
dx#=Rayx2#-Rayx1#
dy#=Rayy2#-Rayy1#
if dist#<>0
nx#=dx#/dist#
ny#=dy#/dist#
else
nx#=0
ny#=0
endif
OldSurface=GetSurface()
rendertoimage ThisImage
lockbuffer
Transparentcolour=GetImageMaskCOlour(ThisImage)
for lp=0 To int(Dist#)
x#=rayx1#+(nx#*lp)
y#=rayy1#+(ny#*lp)
x#=x#-ImageXpos
y#=y#-ImageYpos
if point(X#,y#)<>Transparentcolour
Impactx#=x#+ImageXpos
Impacty#=y#+ImageYpos
Collision=true
exitfor
endif
next
unlockbuffer
rendertoimage OldSurface
endif
EndFunction Collision,ImpactX#,ImpactY#