Total possible triangles = $\binom{16}{3}$ = 560
Now we know that if all points are collinear then the triangle is not possible.
So we will simply deduct the cases wherein we are selecting 3 points which are collinear,
How many groups of 4 collinear points do we have?
4 horizontal lines + 4 vertical lines + 2 diagonals = 10
So $10*\binom{4}{3}=40$ invalid counts
How many groups of 3 collinear points do we have?
Only 4.
So $4*\binom{3}{3}=4$ invalid counts
Therefore the total number of triangles =
560 – (40+4) = 516