public void BeginPaint(gView.Framework.Carto.IDisplay display, ICancelTracker cancelTracker) { if (_bm != null) { _bm.Dispose(); _bm = null; } _bm = (Bitmap)Bitmap.FromFile(_filename); /* * _bmData = _bm.LockBits(new Rectangle(0, 0, _bm.Width, _bm.Height), * ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); */ }
public bool MapRequest(gView.Framework.Carto.IDisplay display) { if (_dataset == null || Themes == null) { return(false); } List <IWebServiceTheme> themes = Themes; #region Check for visible Layers bool visFound = false; foreach (IWebServiceTheme theme in themes) { if (!theme.Visible) { continue; } if (theme.MinimumScale > 1 && theme.MinimumScale > display.mapScale) { continue; } if (theme.MaximumScale > 1 && theme.MaximumScale < display.mapScale) { continue; } visFound = true; break; } if (!visFound) { if (_image != null) { _image.Dispose(); _image = null; } return(true); } #endregion string server = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "server"); string service = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "service"); string user = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "user"); string pwd = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "pwd"); IServiceRequestContext context = display.Map as IServiceRequestContext; if ((user == "#" || user == "$") && context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null) { string roles = String.Empty; if (user == "#" && context.ServiceRequest.Identity.UserRoles != null) { foreach (string role in context.ServiceRequest.Identity.UserRoles) { if (String.IsNullOrEmpty(role)) { continue; } roles += "|" + role; } } user = context.ServiceRequest.Identity.UserName + roles; pwd = context.ServiceRequest.Identity.HashedPassword; } dotNETConnector connector = new dotNETConnector(); if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd)) { connector.setAuthentification(user, pwd); } if (_dataset.State != DatasetState.opened) { if (!_dataset.Open(context)) { return(false); } } ISpatialReference sRef = (display.SpatialReference != null) ? display.SpatialReference.Clone() as ISpatialReference : null; int iWidth = display.iWidth; int iHeight = display.iHeight; if (BeforeMapRequest != null) { BeforeMapRequest(this, display, ref sRef, ref iWidth, ref iHeight); } try { StringBuilder sb = new StringBuilder(); sb.Append("<?xml version='1.0' encoding='utf-8'?>"); sb.Append("<ARCXML version='1.1'>"); sb.Append("<REQUEST>"); sb.Append("<GET_IMAGE>"); sb.Append("<PROPERTIES>"); IEnvelope bounds = display.DisplayTransformation.TransformedBounds(display); if (display.DisplayTransformation.UseTransformation == true) { iWidth = (int)(bounds.Width * display.dpm / display.mapScale); iHeight = (int)(bounds.Height * display.dpm / display.mapScale); } sb.Append("<ENVELOPE minx='" + bounds.minx.ToString() + "' miny='" + bounds.miny.ToString() + "' maxx='" + bounds.maxx.ToString() + "' maxy='" + bounds.maxy.ToString() + "' />"); sb.Append("<IMAGESIZE width='" + iWidth + "' height='" + iHeight + "' />"); sb.Append("<BACKGROUND color='" + Color2AXL(display.BackgroundColor) + "' transcolor='" + Color2AXL(display.TransparentColor) + "' />"); string propertyString = _dataset._properties.PropertyString; if (propertyString != String.Empty) { sb.Append(_dataset._properties.PropertyString); } else { if (sRef != null) { //if (this.SpatialReference != null && !display.SpatialReference.Equals(this.SpatialReference)) { string wkt = gView.Framework.Geometry.SpatialReference.ToESRIWKT(sRef); string geotranwkt = gView.Framework.Geometry.SpatialReference.ToESRIGeotransWKT(sRef); if (wkt != null) { //wkt = "PROJCS[\"MGI_M31\",GEOGCS[\"GCS_MGI\",DATUM[\"D_MGI\",SPHEROID[\"Bessel_1841\",6377397.155,0]],PRIMEM[\"Greenwich\",0.0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",450000],PARAMETER[\"False_Northing\",-5000000],PARAMETER[\"Central_Meridian\",13.3333333333333],PARAMETER[\"Scale_Factor\",1],PARAMETER[\"latitude_of_origin\",0],UNIT[\"Meter\",1]]"; //wkt = "PROJCS[\"MGI_M31\",GEOGCS[\"GCS_MGI\",DATUM[\"D_MGI\",SPHEROID[\"Bessel_1841\",6377397.155,299.1528128]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",450000.0],PARAMETER[\"False_Northing\",-5000000.0],PARAMETER[\"Central_Meridian\",13.33333333333333],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]"; //geotranwkt = "GEOGTRAN[\"MGISTMK_To_WGS_1984\",GEOGCS[\"MGISTMK\",DATUM[\"Militar_Geographische_Institute_STMK\",SPHEROID[\"Bessel_1841\",6377397.155,299.1528128]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],METHOD[\"Position_Vector\"],PARAMETER[\"X_Axis_Translation\",577.326],PARAMETER[\"Y_Axis_Translation\",90.129],PARAMETER[\"Z_Axis_Translation\",463.919],PARAMETER[\"X_Axis_Rotation\",5.1365988],PARAMETER[\"Y_Axis_Rotation\",1.4742],PARAMETER[\"Z_Axis_Rotation\",5.2970436],PARAMETER[\"Scale_Difference\",2.4232]]"; wkt = wkt.Replace("\"", """); geotranwkt = geotranwkt.Replace("\"", """); if (!String.IsNullOrEmpty(geotranwkt)) { sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" datumtransformstring=\"" + geotranwkt + "\" />"); sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" datumtransformstring=\"" + geotranwkt + "\" />"); } else { sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" />"); sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" />"); } //sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" datumtransformid=\"8415\" />"); //sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" datumtransformid=\"8415\" />"); } } } } sb.Append("<LAYERLIST>"); foreach (IWebServiceTheme theme in themes) { sb.Append("<LAYERDEF id='" + theme.LayerID + "' visible='" + (theme.Visible && !theme.Locked).ToString() + "'"); XmlNode xmlnode; if (LayerRenderer.TryGetValue(theme.LayerID, out xmlnode)) { sb.Append(">\n" + xmlnode.OuterXml + "\n</LAYERDEF>"); } else if (theme.FeatureRenderer != null) { string renderer = ObjectFromAXLFactory.ConvertToAXL(theme.FeatureRenderer); sb.Append(">\n" + renderer + "\n</LAYERDEF>"); } else { sb.Append("/>"); } } sb.Append("</LAYERLIST>"); sb.Append("</PROPERTIES>"); foreach (XmlNode additional in this.AppendedLayers) { if (additional != null) { sb.Append(additional.OuterXml); } } sb.Append("</GET_IMAGE>"); sb.Append("</REQUEST>"); sb.Append("</ARCXML>"); #if (DEBUG) gView.Framework.system.Logger.LogDebug("Start ArcXML SendRequest"); #endif ArcIMSClass.Log(display as IServiceRequestContext, "GetImage Request", server, service, sb); string resp = connector.SendRequest(sb, server, service); ArcIMSClass.Log(display as IServiceRequestContext, "GetImage Response", server, service, resp); #if (DEBUG) gView.Framework.system.Logger.LogDebug("ArcXML SendRequest Finished"); #endif XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); XmlNode outputNode = doc.SelectSingleNode("//IMAGE/OUTPUT"); XmlNode envelopeNode = doc.SelectSingleNode("//IMAGE/ENVELOPE"); if (ModifyResponseOuput != null) { ModifyResponseOuput(this, new ModifyOutputEventArgs(outputNode)); } if (_image != null) { _image.Dispose(); _image = null; } #if (DEBUG) //gView.Framework.system.Logger.LogDebug("Start ArcXML DownloadImage"); #endif System.Drawing.Bitmap bm = null; if (outputNode != null) { #if (DEBUG) gView.Framework.system.Logger.LogDebug("Start ArcXML DownloadImage"); #endif bm = WebFunctions.DownloadImage(outputNode /*_dataset._connector.Proxy*/); #if (DEBUG) gView.Framework.system.Logger.LogDebug("ArcXML DownloadImage Finished"); #endif } else { bm = null; } #if (DEBUG) //gView.Framework.system.Logger.LogDebug("ArcXML DownloadImage Finished"); #endif if (bm != null) { _image = new GeorefBitmap(bm); //_image.MakeTransparent(display.TransparentColor); if (envelopeNode != null && envelopeNode.Attributes["minx"] != null && envelopeNode.Attributes["miny"] != null && envelopeNode.Attributes["maxx"] != null && envelopeNode.Attributes["maxy"] != null) { _image.Envelope = new Envelope( Convert.ToDouble(envelopeNode.Attributes["minx"].Value.Replace(".", ",")), Convert.ToDouble(envelopeNode.Attributes["miny"].Value.Replace(".", ",")), Convert.ToDouble(envelopeNode.Attributes["maxx"].Value.Replace(".", ",")), Convert.ToDouble(envelopeNode.Attributes["maxy"].Value.Replace(".", ","))); } _image.SpatialReference = display.SpatialReference; if (AfterMapRequest != null) { AfterMapRequest(this, display, _image); } } return(_image != null); } catch (Exception ex) { ArcIMSClass.ErrorLog(context, "MapRequest", server, service, ex); return(false); } }
public bool LegendRequest(gView.Framework.Carto.IDisplay display) { if (_dataset == null) { return(false); } List <IWebServiceTheme> themes = Themes; if (themes == null) { return(false); } #region Check for visible Layers bool visFound = false; foreach (IWebServiceTheme theme in themes) { if (!theme.Visible) { continue; } if (theme.MinimumScale > 1 && theme.MinimumScale > display.mapScale) { continue; } if (theme.MaximumScale > 1 && theme.MaximumScale < display.mapScale) { continue; } visFound = true; break; } if (!visFound) { if (_legend != null) { _legend.Dispose(); _legend = null; } return(true); } #endregion string server = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "server"); string service = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "service"); string user = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "user"); string pwd = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "pwd"); IServiceRequestContext context = display.Map as IServiceRequestContext; if ((user == "#" || user == "$") && context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null) { string roles = String.Empty; if (user == "#" && context.ServiceRequest.Identity.UserRoles != null) { foreach (string role in context.ServiceRequest.Identity.UserRoles) { if (String.IsNullOrEmpty(role)) { continue; } roles += "|" + role; } } user = context.ServiceRequest.Identity.UserName + roles; pwd = context.ServiceRequest.Identity.HashedPassword; } dotNETConnector connector = new dotNETConnector(); if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd)) { connector.setAuthentification(user, pwd); } if (_dataset.State != DatasetState.opened) { if (!_dataset.Open(context)) { return(false); } } try { StringBuilder sb = new StringBuilder(); sb.Append("<?xml version='1.0' encoding='utf-8'?>"); sb.Append("<ARCXML version='1.1'>"); sb.Append("<REQUEST>"); sb.Append("<GET_IMAGE>"); sb.Append("<PROPERTIES>"); sb.Append("<ENVELOPE minx='" + display.Envelope.minx.ToString() + "' miny='" + display.Envelope.miny.ToString() + "' maxx='" + display.Envelope.maxx.ToString() + "' maxy='" + display.Envelope.maxy.ToString() + "' />"); sb.Append("<IMAGESIZE width='" + display.iWidth + "' height='" + display.iHeight + "' />"); sb.Append("<BACKGROUND color='255,255,255' transcolor='255,255,255' />"); sb.Append(_dataset._properties.PropertyString); sb.Append("<LAYERLIST>"); foreach (IWebServiceTheme theme in themes) { sb.Append("<LAYERDEF id='" + theme.LayerID + "' visible='" + (theme.Visible && !theme.Locked).ToString() + "'"); XmlNode xmlnode; if (LayerRenderer.TryGetValue(theme.LayerID, out xmlnode)) { sb.Append(">\n" + xmlnode.OuterXml + "\n</LAYERDEF>"); } else if (theme.FeatureRenderer != null) { string renderer = ObjectFromAXLFactory.ConvertToAXL(theme.FeatureRenderer); sb.Append(">\n" + renderer + "\n</LAYERDEF>"); } else { sb.Append("/>"); } } sb.Append("</LAYERLIST>"); sb.Append("<DRAW map=\"false\" />"); sb.Append("<LEGEND font=\"Arial\" autoextend=\"true\" columns=\"1\" width=\"165\" height=\"170\" backgroundcolor=\"255,255,255\" layerfontsize=\"11\" valuefontsize=\"10\">"); sb.Append("<LAYERS />"); sb.Append("</LEGEND>"); sb.Append("</PROPERTIES>"); foreach (XmlNode additional in this.AppendedLayers) { sb.Append(additional.OuterXml); } sb.Append("</GET_IMAGE>"); sb.Append("</REQUEST>"); sb.Append("</ARCXML>"); ArcIMSClass.Log(display as IServiceRequestContext, "GetLegend Request", server, service, sb); string resp = connector.SendRequest(sb, server, service); ArcIMSClass.Log(display as IServiceRequestContext, "GetLegend Response", server, service, resp); XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); XmlNode output = doc.SelectSingleNode("//LEGEND"); if (ModifyResponseOuput != null) { ModifyResponseOuput(this, new ModifyOutputEventArgs(output)); } if (_legend != null) { _legend.Dispose(); } _legend = WebFunctions.DownloadImage(output /*_dataset._connector.Proxy*/); return(true); } catch (Exception ex) { ArcIMSClass.ErrorLog(context, "LegendRequest", server, service, ex); return(false); } }
public bool renderImage(gView.Framework.Carto.IDisplay display) { return(false); }
public bool renderLayer(gView.Framework.Carto.IDisplay display, ILayer layer) { return(false); }
public void BeginPaint(gView.Framework.Carto.IDisplay display, ICancelTracker cancelTracker) { IntPtr bufferData = (IntPtr)0; BitmapData bitmapData = null; double mag = 1f; // mag immer als float, läuft stabiler!!! int x = 0; int y = 0; int iWidth = 0; int iHeight = 0; try { if (_reader == (IntPtr)0) { if (!InitReader()) { return; } } if (!(_polygon is ITopologicalOperation) || _reader == (IntPtr)0) { return; } TFWFile tfw = this.GeoCoord as TFWFile; if (tfw == null) { return; } IEnvelope dispEnvelope = display.DisplayTransformation.TransformedBounds(display); //display.Envelope; if (display.GeometricTransformer != null) { dispEnvelope = (IEnvelope)((IGeometry)display.GeometricTransformer.InvTransform2D(dispEnvelope)).Envelope; } IGeometry clipped; ((ITopologicalOperation)_polygon).Clip(dispEnvelope, out clipped); if (!(clipped is IPolygon)) { return; } IPolygon cPolygon = (IPolygon)clipped; // geclipptes Polygon transformieren -> Bild vector2[] vecs = new vector2[cPolygon[0].PointCount]; for (int i = 0; i < cPolygon[0].PointCount; i++) { vecs[i] = new vector2(cPolygon[0][i].X, cPolygon[0][i].Y); } if (!tfw.ProjectInv(vecs)) { return; } IEnvelope picEnv = vector2.IntegerEnvelope(vecs); picEnv.minx = Math.Max(0, picEnv.minx); picEnv.miny = Math.Max(0, picEnv.miny); picEnv.maxx = Math.Min(picEnv.maxx, _geoCoord.iWidth); picEnv.maxy = Math.Min(picEnv.maxy, _geoCoord.iHeight); // Ecken zurücktransformieren -> Welt vecs = new vector2[3]; vecs[0] = new vector2(picEnv.minx, picEnv.miny); vecs[1] = new vector2(picEnv.maxx, picEnv.miny); vecs[2] = new vector2(picEnv.minx, picEnv.maxy); tfw.Project(vecs); _p1 = new gView.Framework.Geometry.Point(vecs[0].x, vecs[0].y); _p2 = new gView.Framework.Geometry.Point(vecs[1].x, vecs[1].y); _p3 = new gView.Framework.Geometry.Point(vecs[2].x, vecs[2].y); double pix = display.mapScale / (display.dpi / 0.0254); // [m] double c1 = Math.Sqrt(_geoCoord.xRes * _geoCoord.xRes + _geoCoord.xRot * _geoCoord.xRot); double c2 = Math.Sqrt(_geoCoord.yRes * _geoCoord.yRes + _geoCoord.yRot * _geoCoord.yRot); mag = Math.Round((Math.Min(c1, c2) / pix), 8); // Immer in auf float runden! Läuft stabiler!!! //mag = (float)mag; //1.03; if (mag > 1f) { mag = 1f; } if (mag < _geoCoord.MinMagnification) { mag = (float)_geoCoord.MinMagnification; } x = (int)(picEnv.minx * mag); y = (int)(picEnv.miny * mag); iWidth = (int)((picEnv.Width - 1) * mag); iHeight = (int)((picEnv.Height - 1) * mag); bufferData = MrSidWrapper.Read(_reader, x, y, iWidth, iHeight, (double)mag); if (bufferData == (IntPtr)0) { return; } int totalWidth = MrSidWrapper.GetTotalCols(bufferData); int totalHeight = MrSidWrapper.GetTotalRows(bufferData); if (_bm != null) { _bm.Dispose(); } _bm = new Bitmap(totalWidth, totalHeight, PixelFormat.Format24bppRgb); bitmapData = _bm.LockBits(new Rectangle(0, 0, totalWidth, totalHeight), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); Console.Write(bitmapData.Scan0); MrSidWrapper.ReadBandData(bufferData, bitmapData.Scan0, (uint)3, (uint)bitmapData.Stride); //_bm.Save(@"C:\temp\pic\" + Guid.NewGuid() + ".jpg", ImageFormat.Jpeg); } catch (Exception ex) { //string errMsg = ex.Message; EndPaint(cancelTracker); if (display is IServiceMap && ((IServiceMap)display).MapServer != null) { IMapServer mapServer = ((IServiceMap)display).MapServer; mapServer.Log( "RenderRasterLayerThread", loggingMethod.error, ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace + "\n" + "filename=" + _filename + "\n" + "x=" + x.ToString() + "\n" + "y=" + y.ToString() + "\n" + "iWidth=" + iWidth.ToString() + "\n" + "iHeight=" + iHeight.ToString() + "\n" + "mag=" + mag.ToString() + "\n"); } else { throw ex; } } finally { if (bitmapData != null) { _bm.UnlockBits(bitmapData); } MrSidWrapper.ReleaseBandData(bufferData); ReleaseReader(); } }
async public Task <IRasterPaintContext> BeginPaint(gView.Framework.Carto.IDisplay display, ICancelTracker cancelTracker) { IntPtr bufferData = (IntPtr)0; GraphicsEngine.BitmapPixelData bitmapData = null; double mag = 1f; // mag immer als float, läuft stabiler!!! int x = 0; int y = 0; int iWidth = 0; int iHeight = 0; GraphicsEngine.Abstraction.IBitmap bitmap = null; try { if (_reader == (IntPtr)0) { if (!InitReader()) { return(null); } } if (!(_polygon is ITopologicalOperation) || _reader == (IntPtr)0) { return(null); } TFWFile tfw = this.GeoCoord as TFWFile; if (tfw == null) { return(null); } IEnvelope dispEnvelope = display.DisplayTransformation.TransformedBounds(display); //display.Envelope; if (display.GeometricTransformer != null) { dispEnvelope = ((IGeometry)display.GeometricTransformer.InvTransform2D(dispEnvelope)).Envelope; } IGeometry clipped; ((ITopologicalOperation)_polygon).Clip(dispEnvelope, out clipped); if (!(clipped is IPolygon)) { return(null); } IPolygon cPolygon = (IPolygon)clipped; if (cPolygon.RingCount == 0 || cPolygon[0].Area == 0D) { return(null); } // geclipptes Polygon transformieren -> Bild vector2[] vecs = new vector2[cPolygon[0].PointCount]; for (int i = 0; i < cPolygon[0].PointCount; i++) { vecs[i] = new vector2(cPolygon[0][i].X, cPolygon[0][i].Y); } if (!tfw.ProjectInv(vecs)) { return(null); } IEnvelope picEnv = vector2.IntegerEnvelope(vecs); picEnv.minx = Math.Max(0, picEnv.minx); picEnv.miny = Math.Max(0, picEnv.miny); picEnv.maxx = Math.Min(picEnv.maxx, _geoCoord.iWidth); picEnv.maxy = Math.Min(picEnv.maxy, _geoCoord.iHeight); // Ecken zurücktransformieren -> Welt vecs = new vector2[3]; vecs[0] = new vector2(picEnv.minx, picEnv.miny); vecs[1] = new vector2(picEnv.maxx, picEnv.miny); vecs[2] = new vector2(picEnv.minx, picEnv.maxy); tfw.Project(vecs); _p1 = new gView.Framework.Geometry.Point(vecs[0].x, vecs[0].y); _p2 = new gView.Framework.Geometry.Point(vecs[1].x, vecs[1].y); _p3 = new gView.Framework.Geometry.Point(vecs[2].x, vecs[2].y); double pix = display.mapScale / (display.dpi / 0.0254); // [m] double c1 = Math.Sqrt(_geoCoord.xRes * _geoCoord.xRes + _geoCoord.xRot * _geoCoord.xRot); double c2 = Math.Sqrt(_geoCoord.yRes * _geoCoord.yRes + _geoCoord.yRot * _geoCoord.yRot); mag = Math.Round((Math.Min(c1, c2) / pix), 8); // Immer in auf float runden! Läuft stabiler!!! //mag = (float)mag; //1.03; if (mag > 1f) { mag = 1f; } if (mag < _geoCoord.MinMagnification) { mag = (float)_geoCoord.MinMagnification; } x = (int)(picEnv.minx * mag); y = (int)(picEnv.miny * mag); iWidth = (int)((picEnv.Width - 1) * mag); iHeight = (int)((picEnv.Height - 1) * mag); bufferData = MrSidWrapper.Read(_reader, x, y, iWidth, iHeight, mag); if (bufferData == (IntPtr)0) { return(null); } int totalWidth = MrSidWrapper.GetTotalCols(bufferData); int totalHeight = MrSidWrapper.GetTotalRows(bufferData); bitmap = GraphicsEngine.Current.Engine.CreateBitmap(totalWidth, totalHeight, GraphicsEngine.PixelFormat.Rgb24); bitmapData = bitmap.LockBitmapPixelData(GraphicsEngine.BitmapLockMode.WriteOnly, GraphicsEngine.PixelFormat.Rgb24); MrSidWrapper.ReadBandData(bufferData, bitmapData.Scan0, 3, (uint)bitmapData.Stride); return(new RasterPaintContext(bitmap)); } catch (Exception ex) { //string errMsg = ex.Message; if (display is IServiceMap && ((IServiceMap)display).MapServer != null) { IMapServer mapServer = ((IServiceMap)display).MapServer; await mapServer.LogAsync( ((IServiceMap)display).Name, "RenderRasterLayerThread", loggingMethod.error, ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace + "\n" + "filename=" + _filename + "\n" + "x=" + x.ToString() + "\n" + "y=" + y.ToString() + "\n" + "iWidth=" + iWidth.ToString() + "\n" + "iHeight=" + iHeight.ToString() + "\n" + "mag=" + mag.ToString() + "\n"); } else { throw ex; } return(null); } finally { if (bitmapData != null) { bitmap.UnlockBitmapPixelData(bitmapData); } MrSidWrapper.ReleaseBandData(bufferData); ReleaseReader(); } }