"Tangent line" is something defined for a line, in case if the "line" is something defined by a function which has a derivative:
http://en.wikipedia.org/wiki/Tangent_line#Tangent_line_to_a_curve[
^].
Your "find tangent" is even more confusing, as the primary meaning of tangent is this:
http://en.wikipedia.org/wiki/Tangent[
^].
Originally, the word is derived from Latin "touch". For example, there is a wonderful musical instrument called "tangent piano".
I have no idea how all this is related to what you want to calculate, because when you say "tangent line", you need to explain how this line is defined, line between what and what, etc. As pixel is not exactly a curve, the tangent line to a pixel does not seem to be a well-defined concept. A tangent line can be defined as a line "touching" another line, not an object like a geometrical point. As to the pixel, it's shape is considered to be undefined, conceptually. :-)
I am ready to believe that the operation you want to perform makes sense, but you need to define things properly. I suspect that when you realize it and read the articles referenced above, you will be able to solve your problem by yourself. If not, formulate it properly and start over.
[EDIT: After OP's clarification:]
Please see the discussion in the comments to this post. The problem is not so simple. I know just one project where such operation is implemented explicitly:
http://en.wikipedia.org/wiki/InkScape[
^],
http://inkscape.org/[
^].
This is the source code:
http://inkscape.org/bzr.php?lang=en[
^].
To download it, you will need Bazaar:
http://en.wikipedia.org/wiki/Bazaar_%28software%29[
^],
http://bazaar.canonical.com/en/[
^].
The product itself is just wonderful, and is practically a must-have anyway, in particular, for everyone who develops the UI. As you have the source code, you can see how the operation you need is done. In this editor, it's done very well. Just look at it, anyway.
Good luck,
—SA