public string Merge(int iWidth, int iHeight, out string imageUrl) { imageUrl = ""; try { DateTime time = DateTime.Now; string filename = "merged_" + time.Day.ToString() + time.Hour.ToString() + time.Second.ToString() + time.Millisecond.ToString() + ".png"; using (var bitmap = GraphicsEngine.Current.Engine.CreateBitmap(iWidth, iHeight, GraphicsEngine.PixelFormat.Rgba32)) using (var canvas = bitmap.CreateCanvas()) using (var brush = GraphicsEngine.Current.Engine.CreateSolidBrush(GraphicsEngine.ArgbColor.White)) { canvas.FillRectangle(brush, new GraphicsEngine.CanvasRectangle(0, 0, iWidth, iHeight)); foreach (string pic in m_picList) { using (var img = GraphicsEngine.Current.Engine.CreateBitmap(pic)) { canvas.DrawBitmap(img, new GraphicsEngine.CanvasRectangle(0, 0, iWidth, iHeight), new GraphicsEngine.CanvasRectangle(0, 0, img.Width, img.Height)); } } if (m_scale > 0) { Scalebar bar = new Scalebar(m_scale, m_dpi); bar.Create(bitmap, bitmap.Width - (int)(50 * m_dpi / 96.0) - bar.ScaleBarWidth, bitmap.Height - (int)(32 * m_dpi / 96.0)); } imageUrl = m_outputUrl + "/" + filename; filename = m_outputPath + @"/" + filename; canvas.Flush(); bitmap.Save(filename, GraphicsEngine.ImageFormat.Png); return(filename); } } catch { return(""); } }
public IEnumerator Init(Scalebar scalebar) { this.scalebar = scalebar; yield return(LoadSavedScales()); // Update Scales UI if (savedScales.Count > 0) { UpdateAllSavedScales(); } ; yield return(LoadSavedLocations()); // Update Locations UI if (savedLocations.Count > 0) { UpdateAllSavedLocations(); } gameObject.SetActive(false); }
public bool Merge(GraphicsEngine.Abstraction.IBitmap bitmap, IDisplay display) { try { int iWidth = bitmap.Width; int iHeight = bitmap.Height; using (var canvas = bitmap.CreateCanvas()) { canvas.CompositingMode = GraphicsEngine.CompositingMode.SourceOver; foreach (GeorefBitmap geoBmp in _picList) { if (geoBmp == null || geoBmp.Bitmap == null) { continue; } if (bitmap != geoBmp.Bitmap) { if (geoBmp.Envelope != null) { double x0, y0, x1, y1, x2, y2; gView.Framework.Geometry.IGeometry geom = gView.Framework.Geometry.GeometricTransformerFactory.Transform2D(geoBmp.Envelope, geoBmp.SpatialReference, display.SpatialReference); if (geom is gView.Framework.Geometry.IPolygon) { gView.Framework.Geometry.IRing ring = ((gView.Framework.Geometry.IPolygon)geom)[0]; x0 = ring[1].X; y0 = ring[1].Y; x1 = ring[2].X; y1 = ring[2].Y; x2 = ring[0].X; y2 = ring[0].Y; ///////////////////////////////////////////////////////// Display d = new Display(display.Map, false); d.Limit = d.Envelope = geoBmp.Envelope; d.iWidth = geoBmp.Bitmap.Width; d.iHeight = geoBmp.Bitmap.Height; d.SpatialReference = geoBmp.SpatialReference; Resample(bitmap, display, geoBmp.Bitmap, d); continue; } else { x0 = geoBmp.Envelope.minx; y0 = geoBmp.Envelope.maxy; x1 = geoBmp.Envelope.maxx; y1 = geoBmp.Envelope.maxy; x2 = geoBmp.Envelope.minx; y2 = geoBmp.Envelope.miny; } display.World2Image(ref x0, ref y0); display.World2Image(ref x1, ref y1); display.World2Image(ref x2, ref y2); GraphicsEngine.CanvasPointF[] points = { new GraphicsEngine.CanvasPointF((float)x0, (float)y0), new GraphicsEngine.CanvasPointF((float)x1, (float)y1), new GraphicsEngine.CanvasPointF((float)x2, (float)y2) }; canvas.DrawBitmap(geoBmp.Bitmap, points, new GraphicsEngine.CanvasRectangleF(0, 0, geoBmp.Bitmap.Width, geoBmp.Bitmap.Height), opacity: geoBmp.Opacity); } else { canvas.DrawBitmap(geoBmp.Bitmap, new GraphicsEngine.CanvasRectangle(0, 0, iWidth, iHeight), new GraphicsEngine.CanvasRectangle(0, 0, geoBmp.Bitmap.Width, geoBmp.Bitmap.Height), opacity: geoBmp.Opacity); } } } } if (_scale > 0) { Scalebar bar = new Scalebar(_scale, m_dpi); bar.Create(bitmap, bitmap.Width - (int)(50 * m_dpi / 96.0) - bar.ScaleBarWidth, bitmap.Height - (int)(32 * m_dpi / 96.0)); } return(true); } catch (Exception ex) { _errMsg = ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace; return(false); } }