|
阅读:1703回复:2
[求助]怎么把gif图片显示在Mapcontrol?
请问各位高手,怎么把gif或PNG图片在MapControl控件里面调显出来啊?偶新手,都被转来转去的接口搞晕了,有没有具体的代码参考一下!谢谢!
|
|
|
1楼#
发布于:2007-09-14 17:30
<P>IPictureElementPtr p(CLSID_BmpPictureElement);<BR> p->ImportPictureFromFile(CComBSTR("C:\\WINNT\\Zapotec.bmp"));<BR> p->put_MaintainAspectRatio(VARIANT_TRUE);<BR> IElementPtr element = p;</P>
<P> IEnvelopePtr ext = m_MapControl.TrackRectangle();<BR> IGeometryPtr g = ext;<BR> element->put_Geometry(g); <BR> ipGraphicsContainer->AddElement(element,0);<BR> ipActiveView->Refresh();</P> |
|
|
|
2楼#
发布于:2007-09-30 17:45
<P>谢谢,我已经解决了,搞了半天原来是pRaster.CreateFromFilePath在Delphi中不支持中文路径!</P>
<P>pMap:=MapControl1.Map; //获得当前地图<BR>pRaster:=CoRasterLayer.Create as IRasterLayer; // 实例化栅格图层 </P> <P>pRaster.CreateFromFilePath('E:\temp\xy.GIF'); //不能用中文图片名称,创建一个栅格图层<BR>pMap.AddLayer(pRaster); //在当前地图上添加栅格</P> |
|