How do I translate mouse coordinates into world coordinates using GDI+? Or get bounding boxes (or even better) old skool regions for SVG shapes drawn using GDI+?
Anyway. I've been looking for SVG code and found:
http://development.mwcs.de/svgimage.html
This is the first Delphi component that actually works for SVG, but I digress.
This component uses GDI+ to display circles, curves etc.
GDI+ uses matrixes to convert world coordinates, rotations and distortions into screen coordinates.
This part I understand. You use matrix multiplication to do the translation.
The problem is this
If I point my mouse cursor over a closed shape:
- Where do I get the matrix from that will translate my screen-point of my mouse to a world point that I can hittest into the circle that I see drawn on the screen?
There are soo many matrixes to choose from in all those GDI objects. - Please don't give me stuff about drawing to a bitmap and testing for magic colors under the cursor, this is not what I'm looking for.
- If there is a chain of matrixes, how do I traverse them in the correct (inverted?) order so that my screen coordinate gets guided correctly to the world coordinate?
In other words
The shapes that are read in from an SVG image are primitives that get distorted by matrixes into screen-coordinates.
How do I do the reverse from a screen coordinate into the coordinates that I can use to see if I'm inside a shape or not.
please note
I need to know which shape I am in.
Because of the way the SVG image is set up, each shape has an id, and I want to use that to see what region I have hit with my mouse.
EDIT
Alternatively
- Can I get a bounding rect per shape in screen coordinates so I can check my mouse coordinates against that.
- Can I get a old skool GDI region where I can do a PtInRegion with in screen coordinates.
Hope you can help me find my way with all these distorted paths :-).