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(); }
  • 相关阅读:
    【转】【SEE】基于SSE指令集的程序设计简介
    【转】【Asp.Net】asp.net服务器控件创建
    ControlTemplate in WPF ——ScrollBar
    ControlTemplate in WPF —— Menu
    ControlTemplate in WPF —— Expander
    ControlTemplate in WPF —— TreeView
    ControlTemplate in WPF —— ListBox
    ControlTemplate in WPF —— ComboBox
    ControlTemplate in WPF —— TextBox
    ControlTemplate in WPF —— RadioButton
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/2442295.html
Copyright © 2011-2022 走看看