|
阅读:1316回复:0
[求助]导入图片怎么进行配准?
<P>有一张.jpg图片, 比如说宽高分别是500, 500。 </P>
<P>以图片左上角为基准,我想将此图片配准如下:</P> <TABLE border=1 cellSpacing=2 borderColor=#cccccc cellPadding=3 width="100%" bgColor=#ffffff align=center> <TR> <TD> 像素点坐标</TD> <TD> 经纬度坐标</TD> <TR> <TD> (0, 0)</TD> <TD> (0, 0)</TD> <TR> <TD> (0, 500)</TD> <TD> (0, 1)</TD> <TR> <TD> (500, 500)</TD> <TD> (1, 1)</TD></TR></TABLE> <P>由于初次使用Arcgis, 不是很懂。网上google了下,以下是我的实现代码。运行结果是MapControl上没任何显示。不知道为什么?代码逻辑很简单,麻烦大家帮我看看。谢谢了。</P> <DIV class=HtmlCode>//三点配准<BR>{<BR> IGeoReferencePtr pGeoRef;<BR> hr = pLayer.QueryInterface(__uuidof(IGeoReference), ;pGeoRef);<BR> if(!SUCCEEDED(hr))<BR> continue; <P> VARIANT_BOOL canGeoRef = false;<BR> hr = pGeoRef->get_CanGeoRef(;canGeoRef);<BR> if(!SUCCEEDED(hr) || !canGeoRef)<BR> continue;<BR> <BR> IRasterPtr pRaster;<BR> hr = pLayer->get_Raster(;pRaster);<BR> if(!SUCCEEDED(hr))<BR> continue;</P> <P> IRasterPropsPtr pRasterProps;<BR> hr = pRaster.QueryInterface(__uuidof(IRasterProps), ;pRasterProps);<BR> if(!SUCCEEDED(hr))<BR> continue;</P> <P> long width, height;<BR> hr = pRasterProps->get_Width(;width);<BR> if(!SUCCEEDED(hr))<BR> continue;<BR> hr = pRasterProps->get_Height(;height);<BR> if(!SUCCEEDED(hr))<BR> continue;</P> <P> IPointCollectionPtr fromPts(CLSID_Polyline);</P> <P> IPointPtr fromPointLeftTop(CLSID_Point);<BR> hr = fromPointLeftTop->PutCoords(0, 0);<BR> hr = fromPts->AddPoint(fromPointLeftTop);</P> <P> IPointPtr fromPointLeftButtom(CLSID_Point);<BR> hr = fromPointLeftButtom->PutCoords(0, height);<BR> hr = fromPts->AddPoint(fromPointLeftTop);</P> <P> IPointPtr fromPointRightButtom(CLSID_Point);<BR> hr = fromPointRightButtom->PutCoords(width, height);<BR> hr = fromPts->AddPoint(fromPointRightButtom);</P> <P><BR> IPointCollectionPtr toPts(CLSID_Polyline);</P> <P> IPointPtr toPointLeftTop(CLSID_Point);<BR> hr = toPointLeftTop->PutCoords(0, 0);<BR> hr = toPts->AddPoint(toPointLeftTop);</P> <P> IPointPtr toPointLeftButtom(CLSID_Point);<BR> hr = toPointLeftButtom->PutCoords(0, 1);<BR> hr = toPts->AddPoint(toPointLeftButtom);</P> <P> IPointPtr toPointRightButtom(CLSID_Point);<BR> hr = toPointRightButtom->PutCoords(1, 1);<BR> hr = toPts->AddPoint(toPointRightButtom);</P> <P> hr = pGeoRef->Warp(fromPts, toPts, 0);<BR> if(!SUCCEEDED(hr))<BR> continue;</P> <P> hr = pGeoRef->Register();<BR> if(!SUCCEEDED(hr))<BR> continue;<BR> }</P> <P> IMapControl4Ptr smpMapControl = GetView()->GetMapControl()->GetIMapControl4Ptr();<BR> hr = smpMapControl->AddLayer(pLayer, 0); <BR> if(!SUCCEEDED(hr))<BR> continue;</P></DIV> |
|