vb.net - How to correctly draw to map coordinates in gdi+ -
i have large scanned map want use in order display location of moving target
i load map picture box inside panel
- the panel set auto-scroll. picture box size mode set auto_size
in order calculate transformation let user sample 3 points calculate affine transformation matrix
[x' y' 1] = [x y 1] * [a b 0 c d 0 e f 1]
i know transformation successful because mouse hover event displays correct coordinates:
private sub picmap_mousemove(byval sender object, byval e system.windows.forms.mouseeventargs) handles picmap.mousemove if _calibsuccess dim curpoint(0) pointf curpoint(0).x = e.x : curpoint(0).y = e.y dim genericgraphics drawing.graphics = creategraphics() dim mat drawing2d.matrix = new drawing2d.matrix(mdlglobal._georefparams(0), mdlglobal._georefparams(3), _ mdlglobal._georefparams(1), mdlglobal._georefparams(4), _ mdlglobal._georefparams(2), mdlglobal._georefparams(5)) genericgraphics.transform = mat genericgraphics.transformpoints(drawing2d.coordinatespace.device, drawing2d.coordinatespace.world, curpoint) lblx.text = curpoint(0).x lbly.text = curpoint(0).y else lblx.text = e.x lbly.text = e.y end if end sub
but when try draw marker on screen nothing
private sub picmap_paint(byval sender object, byval e system.windows.forms.painteventargs) handles picmap.paint dim drawgraphics graphics = e.graphics if _calibsuccess , _broadcasting dim mat drawing2d.matrix = new drawing2d.matrix(mdlglobal._georefparams(0), mdlglobal._georefparams(3), _ mdlglobal._georefparams(1), mdlglobal._georefparams(4), _ mdlglobal._georefparams(2), mdlglobal._georefparams(5)) drawgraphics.resettransform() drawgraphics.transform = mat drawgraphics.fillrectangle(brushes.red, _shipbase.x - (100.0f / 3600.0f), _shipbase.y - (100.0f / 3600.0f), (200.0f / 3600.0f), (200.0f / 3600.0f)) end if end sub
could tell me doing wrong?
your transform matrix inverse of needs be. can tell because transformpoints call going world device coordinates, mouse input in device coordinates.
Comments
Post a Comment