Following the answer by Yves Klett on a practically identical question, this is easily computed via Solve
(or any related equation-solving functions), you only have to be careful when you have a vertical line (ie. $x_1 = x_2$):
findIntegerSolutions[{x1_, y1_}, {x2_, y2_}] := Module[{line, x, y},
line = If[x1 == x2, x == x1, y - y1 == (y2 - y1)/(x2 - x1) (x - x1)];
SolveValues[line && {x} ∈ Interval[{x1, x2}] && {y} ∈ Interval[{y1, y2}],
{x, y}, Integers]
]
findIntegerSolutions[{45/2, 0}, {45/3, -45/3}]
(* {{15, -15}, {16, -13}, {17, -11}, {18, -9}, {19, -7}, {20, -5},
{21, -3}, {22, -1}} *)
findIntegerSolutions[{21, 0}, {21, 10/5}]
(* {{21, 0}, {21, 1}, {21, 2}} *)
Or an even simpler solution, as given by @ydd:
findIntegerSolutions[a_, b_] :=
Module[{x}, SolveValues[x ∈ Line[{a, b}], x, Integers]]