Click on and color a line in a tiff file.

I am looking to click on a line in a tiff file and color the line with a color.
See this video
Looking for a solution in Delphi Community Edition.
This is a schematic and the ideal is to click on a line  go from junction to junction ( BLACK DOT) in the schematic.
The schematics will always be black and white.
Grant FullenNONEAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
I wonder why you need solution in Delphi?
Nevertheless, here on  you'll find lots of useful algorithms which can help you to replace certain color with another.... Main thing is to detect nearest nodes and draw line in between in another color following existing one. And here is one more example how to replace color.
Grant FullenNONEAuthor Commented:
@Sinisa Vuk  Thanks for you comment.
I will look at the Bitmap example you posted.
I an using a tiff file  so may not work with the bitmap examples.
Grant FullenNONEAuthor Commented:
ANyone have an Ideal how to acheave this ?
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Geert GOracle dbaCommented:
you can't "click" on a line in file

the concept is to open the .tiff and loading it into a TGraphic
this .tiff will then have a Canvas in Delphi with which you can interact via code/api's

you can click on the image component and need to translate the mouse click to the relevant coordinates on the canvas

and then save the image back to the .tiff file

loading the image:
procedure LoadBitmapFromFile( aImage : TImage; tiffFilename : String);
  tiffIm : TWICImage;
  ext : String;
  ext := SysUtils.ExtractFileExt(tiffFilename);
  if (ext = '.tif') or (ext = '.tiff')
    then aImage.Picture.LoadFromFile(tiffFilename)
    else begin
      tiffIm:= TWICImage.Create;

Open in new window

See also TWICImage,

manipulating the image to color a line is done with the moveto and linto from Tcanvas

setting the color is done by calling Canvas.Pen.Color = ...
Grant FullenNONEAuthor Commented:
Thanks for your help.
I will look at this solution.
Grant FullenNONEAuthor Commented:
Thanks for your help with that example.
That looks like you will be clicking on a point on the canvas and dragging your mouse and letting go and drawing a line.

If you look at the video link you will see that the mouse clicks on the line in the tiff and draws the line from point to point this is what I am looking to do in Delphi.
Again thanks very much for you help.
Geert GOracle dbaCommented:
i can't remember seeing that video link there

i just thought you wanted to click anywhere and draw line

a lot of work involved in what you ask ...
you need an algorithm to determine the boundaries
how i would do it:
  determine vertical or horizontal direction by checking pixels left/right or above/below on color
  determine width of line
  find boundaries > checking width of line in direction
  create a clipping region a few pixels in width and from start to finish boundary
  floodfill the point clicked, clipped by the region

the floodfill will find adjacent pixels with the same color and stop at the clipping region

sample clipping region

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Grant FullenNONEAuthor Commented:
Thanks for the help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.