Click on and color a line in a tiff file.

Grant Fullen
Grant Fullen used Ask the Experts™
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.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sinisa VukSoftware architect
Top Expert 2012

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.


@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.


ANyone have an Ideal how to acheave this ?
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Geert GOracle dba
Top Expert 2009

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 = ...


Thanks for your help.
I will look at this solution.


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.
Oracle dba
Top Expert 2009
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


Thanks for the help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial