浏览问题
等待回复
精选文章
申请试用
资源中心
漏洞修复
注册
|
登录
SuperMap技术问答社区
我要
提问
智能客服
首页
/
浏览问题
/
组件GIS
/
问题详情
.Net objects 标绘图片
cherish
31EXP
2017年04月11日
二、三维标绘图片使用GeoPicture、GeoPicture3D中根据指定的参数来构造一个 GeoPicture、GeoPicture3D 的新对象中的 string imageFile 分别需要什么格式的?
组件
三维
1个回答
你好,一般的图片格式都是支持的,比如PNG,JPG等格式
胡林
5,985EXP
2017年04月11日
你看我这样写有什么问题不,添加图片了没效果。
private void m_sceneControl_MouseClick(object sender, MouseEventArgs e)
{
try
{
if (e.Button == MouseButtons.Left )
{
//画点
if (m_WorkMode == WorkMode.Plot)
{
if(m_PlotType == PlotType.Text)
{
FormTextInput frmText = FormTextInput.Instance;
if (frmText == null || frmText.IsDisposed) return;
if (m_cadLayer.IsEditable)
{
frmText.Load += (_sender, _e) =>
{
frmText.Location = new System.Drawing.Point(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y);
frmText.BtnOkClickEvent += (text) =>
{
if (string.IsNullOrEmpty(text))
{
XtraMessageBox.Show("字符不能为空!", "提示");
return;
}
DatasetVector cadDataset = m_workspace.Datasources[0].Datasets["cad"] as DatasetVector;
Recordset recordset = cadDataset.GetRecordset(false, CursorType.Dynamic);
recordset.MoveLast();
Point3D pt3d = new Point3D();
pt3d = m_sceneControl.Scene.PixelToGlobe(e.Location, PixelToGlobeMode.TerrainAndModel);
GeoText3D geoText = new GeoText3D(new TextPart3D(text, pt3d));
SetResultTextStyle(geoText);
frmText.Close();
recordset.AddNew(geoText);
recordset.Update();
recordset.Dispose();
m_cadLayer.IsSelectable = false;
m_cadLayer.UpdateData();
m_sceneControl.Scene.Refresh();
};
};
frmText.ShowDialog();
}
}
else if (m_PlotType == PlotType.Image)
{
//打开图片对话框
using (OpenFileDialog op = new OpenFileDialog())
{
op.Title = "打开图片文件";
op.Multiselect = false;
op.CheckFileExists = true;
op.Filter = "支持的图像格式(*.png,*.jpg,*.jpeg,*.gif,*.bmp)|*.png;*.jpg;*.jpeg;*.gif;*.bmp";
if (op.ShowDialog() == DialogResult.OK)
{
string fileName = op.FileName;
if (!System.IO.File.Exists(fileName)) return;
DatasetVector cadDataset = m_workspace.Datasources[0].Datasets["cad"] as DatasetVector;
Recordset recordset = cadDataset.GetRecordset(false, CursorType.Dynamic);
recordset.MoveLast();
Point3D pt3d = new Point3D();
pt3d = m_sceneControl.Scene.PixelToGlobe(e.Location, PixelToGlobeMode.TerrainAndModel);
GeoPicture3D geoPicture = new GeoPicture3D(fileName, pt3d, 0.5, 0.5, 0);
recordset.AddNew(geoPicture);
recordset.Update();
recordset.Dispose();
m_cadLayer.IsSelectable = false;
m_cadLayer.UpdateData();
m_sceneControl.Scene.Refresh();
}
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
添加文本是正常的,你不用看,看下面的添加图片
你好,CAD数据集是不能存图片对象的,一般我们存图片信息是在数据集中新建一个二进制的字段,然后把图片以二进制的形式存储在字段中,示范代码下面给你贴出来
DatasetVector datasetvc = _workspace.Datasources[0].Datasets["s111"] as DatasetVector;
FieldInfo fieldinfo1 = new FieldInfo();
fieldinfo1.Name = "pic";
fieldinfo1.Caption = "pic";
fieldinfo1.Type = FieldType.LongBinary;
fieldinfo1.IsRequired = false;//新建二进制字段
datasetvc.FieldInfos.Add(fieldinfo1);//datasetvc是矢量数据集
FileStream fs = new FileStream(@"C:\Users\Administrator\Desktop\第一季度考核\三维动态标绘.png", FileMode.Open);
byte[] byData = new byte[fs.Length];
fs.Read(byData, 0, byData.Length);
fs.Close();
Recordset reco = datasetvc.GetRecordset(false, CursorType.Dynamic);
reco.MoveFirst();
reco.Edit();
bool a= reco.SetLongBinary("pic",byData);
reco.Update();
那我想要在地图上显示图片用这种方式可以实现不,因为绘制都是放在CAD数据集中,我就想着图片也放在CAD数据集中
程序是可以控制的,当你打开场景的时候,就将数据集中的图片信息读取出来,然后再显示出来就好了
那点击地图添加图片还是用这种方式吗
Point3D pt3d = new Point3D();
pt3d = m_sceneControl.Scene.PixelToGlobe(e.Location, PixelToGlobeMode.TerrainAndModel);
GeoPicture3D geoPicture = new GeoPicture3D(fileName, pt3d, 0.5, 0.5, 0);
recordset.AddNew(geoPicture);
你是想点击一个点就在那个点的位置添加一个图片吗
是的,我想实现二、三维都实现点击一个点就在那个点的位置添加一个图片。
这个就使用地标功能(GeoPlacemark)来实现比较好,把图片作为一个地标,然后添加到KML图层上
//打开图片对话框
using (OpenFileDialog op = new OpenFileDialog())
{
op.Title = "打开图片文件";
op.Multiselect = false;
op.CheckFileExists = true;
op.Filter = "支持的图像格式(*.png,*.jpg,*.jpeg,*.gif,*.bmp)|*.png;*.jpg;*.jpeg;*.gif;*.bmp";
if (op.ShowDialog() == DialogResult.OK)
{
string fileName = op.FileName;
if (!System.IO.File.Exists(fileName)) return;
DatasetVector cadDataset = m_workspace.Datasources[0].Datasets["cad"] as DatasetVector;
Recordset recordset = cadDataset.GetRecordset(false, CursorType.Dynamic);
recordset.MoveLast();
Point3D pt3d = new Point3D();
pt3d = m_sceneControl.Scene.PixelToGlobe(e.Location, PixelToGlobeMode.TerrainAndModel);
GeoPicture3D geoPicture = new GeoPicture3D(fileName, pt3d, 1, 1, 90);
recordset.AddNew(geoPicture);
recordset.Update();
recordset.Dispose();
m_cadLayer.IsSelectable = false;
m_cadLayer.UpdateData();
m_sceneControl.Scene.Refresh();
}
}
二维这样写可以了,三维这样写不行,不知道有什么问题,是三维支持的图片格式不同吗?
二维地图可以将图片添加到跟踪图层(TrackingLayer)上面,三维场景建议使用地标(GeoPlacemark)或者气泡(Bubble)来显示图片比较好,当然也可以添加到跟踪图层,只是需要调整好图片的大小。屏幕图层(ScreenLayer)虽然也可以添加图片,但显示出来的图片大小是固定的,不会随图缩放,一般是用来做logo的显示。
二维你是怎么添加上去的,也是把对象直接添加到CAD数据集中?
是的,这样是可以的
if (m_PlotType == PlotType.Image)
{
//打开图片对话框
using (OpenFileDialog op = new OpenFileDialog())
{
op.Title = "打开图片文件";
op.Multiselect = false;
op.CheckFileExists = true;
op.Filter = "支持的图像格式(*.png,*.jpg,*.jpeg,*.gif,*.bmp)|*.png;*.jpg;*.jpeg;*.gif;*.bmp";
if (op.ShowDialog() == DialogResult.OK)
{
string fileName = op.FileName;
if (!System.IO.File.Exists(fileName)) return;
DatasetVector cadDataset = m_workspace.Datasources[0].Datasets["cad"] as DatasetVector;
Recordset recordset = cadDataset.GetRecordset(false, CursorType.Dynamic);
recordset.MoveLast();
Point2D pt2d = new Point2D();
pt2d = m_mapControl.Map.PixelToMap(e.Location);
GeoPicture geoPicture = new GeoPicture(fileName, pt2d, 1, 1, 0);
recordset.AddNew(geoPicture);
recordset.Update();
recordset.Dispose();
m_cadLayer.IsSelectable = false;
m_mapControl.Map.Refresh();
}
}
}
我试了一下,二三维都是可以存进CAD数据集的,也能够显示出来。
你可以做断点看一下recordset.AddNew(geoPicture);这一句是否添加成功了,还有就是通过属性表看一下对象是否加进去了。
GeoPicture geoPicture = new GeoPicture(fileName, pt2d, 1, 1, 0);这里设置图片的宽度和高度是不是有点小
这个单位是米哦
我三维下recordset.AddNew(geoPicture) 返回的是false,你是怎么写的?
我跟你写得差不多一样,你看看三维点获取的对不对,看一下pt3d获取到的坐标
我看了一下,我的对象是添加进去了,但是经纬度设置的位置没起作用,下面是我的代码,单位是度
Point3D point3d = new Point3D(116.45, 40.91,10);//图片不在这个位置
DatasetVector datasetCAD = datasetcheck as DatasetVector;
Recordset reco = datasetCAD.GetRecordset(false, CursorType.Dynamic);
_openfile = new OpenFileDialog();
_openfile.Filter = "jpg文件(.jpg)|*.jpg*";
if (_openfile.ShowDialog() == DialogResult.OK)
{
string filename = _openfile.FileName;
Bitmap pic = new Bitmap(filename);
double width = pic.Width;
double height = pic.Height;
GeoPicture3D geopictrue = new GeoPicture3D(filename, point3d, width / 10000, height / 10000, 180);
//screenlayer.Add(geopictrue,"logo");
bool a= reco.AddNew(geopictrue);
reco.Update();
设置的位置没起作用
请
登录
或者
注册
后再添加评论。
智能推荐
相关问题
相关文章
推荐教程
.net objects二、三维要素闪烁
标绘功能有的显示在场景下方
标绘 如何用代码直接在场景上绘制
.net开发桌面端应用程序,场景中绘制图形
.net组件Scene.EnsureVisible方法问题
组件开发中 绘制一个多边形,如何均匀的布点呢?
.NET开发中根据经纬度在地图中添加自定义图标
iobjects.Net的坐标点显示
热门文章
查看更多>
关注我们
超图软件官网
SuperMap Online
地图慧
帮助中心
备案信息
技术资源中心
...