zoukankan      html  css  js  c++  java
  • arcgis featureclass的blob字段

    图片存入SDE blob 字段 : private void UpdateRasterToSDE() { try { OpenFileDialog openFile = new OpenFileDialog(); DialogResult result = openFile.ShowDialog(); if (openFile.FileName == "" || openFile.FileName == null) return; ITable pTable; ICursor cursor; IFeatureCursor featureCursor; IQueryFilter filter = new QueryFilterClass(); pTable = ((IFeatureSelection)m_CurFeatureLayer).SelectionSet.Target; IFeature feature = new FeatureClass_2(); IMemoryBlobStream pMemoryStream = new MemoryBlobStreamClass(); pMemoryStream.LoadFromFile(openFile.FileName); bool isEditing = false; if (m_CurFeatureLayer != null) { if (Form1.mapEdit.IsEditing()) isEditing = true; IWorkspaceEdit wspEdit; wspEdit = ((IDataset)((IFeatureSelection)m_CurFeatureLayer).SelectionSet.Target).Workspace as IWorkspaceEdit; wspEdit.StartEditing(true); wspEdit.StartEditOperation(); int OID = 0; for (int i = 0; i < dataGridView2.Columns.Count; i++) { if (dataGridView2.Columns[i].Name == pTable.OIDFieldName) { OID = i; } } filter.WhereClause = dataGridView2.Columns[OID].Name + " = " + dataGridView2.Rows[pRow].Cells[OID].Value.ToString(); cursor = pTable.Search(filter, true); featureCursor = cursor as IFeatureCursor; feature = featureCursor.NextFeature(); if (feature == null) return; IRow Row = (IRow)feature;//也可以不转换,直接用feature存入 Row.set_Value(pColumn, pMemoryStream); Row.Store(); wspEdit.StopEditOperation(); wspEdit.StopEditing(true); if (isEditing) Form1.mapEdit.StartEdit(); } } catch { MessageBox.Show("图片数据过大,请加入小于1M的图片!");//或者是其他问题,不详述 } DataGridViewTextBoxCell textboxcell = (DataGridViewTextBoxCell)dataGridView2.Rows[pRow].Cells[pColumn]; textboxcell.Value = "有"; } 图片读出: private void ViewToolStripMenuItem_Click(object sender, EventArgs e) { Viewer viewer=new Viewer(); Image image; IMemoryBlobStreamVariant pMemoryStream = new MemoryBlobStreamClass(); int row=0; IFeatureCursor feaCursor=m_CurFeatureLayer.Search(null,true); IFeature feature=feaCursor.NextFeature(); for (int i = 0; i < dataGridView2.Columns.Count; i++) { if (m_CurFeatureLayer.FeatureClass.OIDFieldName == dataGridView2.Columns[i].Name) row = i; } DataGridViewTextBoxCell textboxcell = (DataGridViewTextBoxCell)dataGridView2.Rows[pRow].Cells[row]; while (feature != null) { if (feature.OID == Convert.ToInt32(textboxcell.Value.ToString())) break; feature = feaCursor.NextFeature(); } pMemoryStream = (IMemoryBlobStreamVariant)feature.get_Value(feature.Fields.FindField("ZDTP")); object obj; pMemoryStream.ExportToVariant(out obj); byte[] img; img = (byte[])obj; MemoryStream memoryStream = new MemoryStream(img); image = Image.FromStream(memoryStream); memoryStream.Close(); viewer = new Viewer(image); viewer.Show(); }
  • 相关阅读:
    李彦宏演讲被泼水:演讲时遇到意外情况该如何处理?
    人工智能,能为教育带来哪些改变?
    重磅!Python又第一了!网友:为什么找不到好工作?真相让人脸红…
    《营销管理必读12篇》读后感
    战略管理好书推荐,《战略管理必读12篇》位居榜首
    企业管理十大书
    童话里都是骗人的?用词向量解析故事中的性别偏见
    《领导力必读12篇》:领导力提升的艺术
    领导力提升:你找对方法了吗?
    分布式系统阅读笔记(十)-----P2P对等网络系统
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/2442295.html
Copyright © 2011-2022 走看看