It's theoretically possible to replicate the exact line drawing algorithm (i.e.
Bresenham's line algorithm) used by
TCanvas.Line() and handle the to-be-overwritten pixels beforehand, but unfortunately
TCanvas is just a wrapper around some widget set functions, which are platform-dependent (i.e. on Windows,
LineTo from
gdi32.dll does the actual drawing - obviously not possible on, say, Linux).
But there's a more general approach, which can detect changes between any two images (but requiring more resources):
- Subtract the modified image from the original (result will be black everywhere except at the modifications)
- Generate a black/white mask by e.g. defining a cutoff (the black regions will be discarded, the white regions kept)
- Multiply the original image with the mask (result is a cutout of the original of all overwritten regions)