http://blog.csdn.net/mygisforum/article/details/22478491
除了上述步骤以外,还需要把bin目录下所有的文件(除了文件夹)拷到debug目录下即可成功
测试代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OSGeo.GDAL;
namespace gdal
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
SharpMap.GdalConfiguration.ConfigureGdal();
SharpMap.GdalConfiguration.ConfigureOgr();
OSGeo.GDAL.Gdal.AllRegister();
OSGeo.GDAL.Dataset dataSet = OSGeo.GDAL.Gdal.Open(@"C:\1237.jpg", Access.GA_ReadOnly);
int w = dataSet.RasterXSize;
int h = dataSet.RasterYSize;
MessageBox.Show("image width=" + w + ",height=" + h);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
}