I also noticed that when the image is added using AddLayer(), the image also cannot be saved from the layer reference in the MapWinGIS control.
Grids files that start out as ArcInfo grids converted to Geotiff don't seem to exhibit this problem. It's very odd. Any similar problems noted?
Comments: ** Comment from web user: sleschinski **
I checked the issue (the test code is below). It worked fine, resulting tif image isn't corrupted. Our new GlobalSettings.ApplicationCallback reported a number of warning though, but they can be false positives (I'll check them). The list is below. I also added callback to report saving progress: https://mapwingis.codeplex.com/SourceControl/changeset/75313
As a pure guess an issue can be caused by missing # pragma pack(pop) directive in one of our files (sets alignment of structures). I recently fixed it, as there were inexplicable memory corruption problems. They seem to be gone after that.
@gstandard, please check if the issue is still there for you / can you reproduce it with my test code.
Here is the test code.
```
var gs = new GlobalSettings();
gs.GridProxyFormat = tkGridProxyFormat.gpfTiffProxy;
string filename = @"d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image.img";
if (!File.Exists(filename))
{
MessageBox.Show("File wasn't found: " + filename);
return;
}
var grid = new Grid();
if (!grid.Open(filename, GridDataType.UnknownDataType, false))
{
MessageBox.Show("Failed to open grid.");
return;
}
else
{
Debug.Print("Number of bands: " + grid.NumBands);
}
var gcs = grid.GenerateColorScheme(tkGridSchemeGeneration.gsgGradient, PredefinedColorScheme.SummerMountains);
if (gcs == null)
{
grid.Close();
MessageBox.Show("Failed to generated color scheme.");
return;
}
var img = grid.OpenAsImage(gcs, tkGridProxyMode.gpmUseProxy);
if (img == null)
{
grid.Close();
MessageBox.Show("Failed to create proxy.");
return;
}
bool result = img.Save(@"d:\img_proxy.tif", true);
MessageBox.Show("Image proxy is saved: " + result.ToString());
img.Close();
grid.Close();
```
Here is the list of reported warnings (GDAL_FAILURE are internal error messages of GDAL):
GDAL FAILURE: No translation for an empty SRS to PROJ.4 format is known.
GeoProjection: OGR: Zero Length String
GDAL FAILURE: Only OGC WKT Projections supported for writing to GeoTIFF.
+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs not supported.
GDAL FAILURE: d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image_proxy.tif, band 1: The buffer into which the data should be read is null
GDAL FAILURE: d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image_proxy.tif, band 2: The buffer into which the data should be read is null
GDAL FAILURE: d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image_proxy.tif, band 3: The buffer into which the data should be read is null
Image: The method or property isn't applicable to GDAL images.
GDAL WARNING: driver GTiff does not support creation option WORLDFILE