Size IOverviewGenerator.ComputeSize(int maxSize) { TryCreateOverviewGenerator(); if (_overviewGenerator != null) { return(_overviewGenerator.ComputeSize(maxSize)); } return(Size.Empty); }
private static Bitmap GenerateOverview(IRasterDataProvider prd, int[] bandNos, int maxSize) { CoordEnvelope env = prd.CoordEnvelope; IOverviewGenerator v = prd as IOverviewGenerator; Size size = v.ComputeSize(maxSize);//缩略图最大不超过的尺寸 Bitmap bm = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb); v.Generate(bandNos, ref bm); return(bm); }
private void UpdateBuffer() { ICanvasViewer viewer = _session.SmartWindowManager.ActiveCanvasViewer; if (viewer == null || viewer.ActiveObject == null) { return; } IRasterDrawing drawing = viewer.ActiveObject as IRasterDrawing; if (drawing == null || drawing.DataProvider == null) { return; } using (IRasterDataProvider prd = GeoDataDriver.Open(drawing.FileName) as IRasterDataProvider) { IOverviewGenerator ov = prd as IOverviewGenerator; if (ov == null) { return; } Size size = ov.ComputeSize(200); if (_buffer != null) { _buffer.Dispose(); } _defaultBands = GetDefaultBands(prd); if (_defaultBands == null || _defaultBands.Length == 0) { return; } if (_defaultBands.Length == 3) { _buffer = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb); } else if (_defaultBands.Length == 1) { _buffer = new Bitmap(size.Width, size.Height, PixelFormat.Format8bppIndexed); _buffer.Palette = BitmapBuilderFactory.GetDefaultGrayColorPalette(); } else { return; } // ov.Generate(_defaultBands, ref _buffer); // _resX = drawing.OriginalEnvelope.Width / _buffer.Width; _resY = drawing.OriginalEnvelope.Height / _buffer.Height; } }
private Bitmap GenerateOverview(IRasterDataProvider prd, int[] bandNos) { CoordEnvelope env = prd.CoordEnvelope; if (env != null) { Envelope = new PrjEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY); } IOverviewGenerator v = prd as IOverviewGenerator; Size size = v.ComputeSize(1000);//缩略图最大不超过的尺寸 Bitmap bm = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb); v.Generate(bandNos, ref bm); return(bm); }
private void AVILayer_Click(object sender, EventArgs e) { string[] fnames = null; using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Filter = "栅格文件(*.dat)|*.dat"; dlg.Multiselect = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fnames = dlg.FileNames; } else { return; } } IRasterDataProvider prd; List <Bitmap> bmps = new List <Bitmap>(); Bitmap bp; foreach (string fname in fnames) { using (prd = GeoDataDriver.Open(fname) as IRasterDataProvider) { IOverviewGenerator ovg = prd as IOverviewGenerator; Size size = ovg.ComputeSize(800); bp = new Bitmap(size.Width, size.Height, PixelFormat.Format8bppIndexed); bp.Palette = BitmapBuilderFactory.GetDefaultGrayColorPalette(); ovg.Generate(new int[] { 1 }, ref bp); if (bp != null) { bmps.Add(bp); } } } if (bmps.Count == 0) { return; } //IAVILayer aviLyr = new AVILayer(bmps.ToArray(), new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(112, 113, 39, 40), 500); //aviLyr.IsRunning = true; //_canvas.LayerContainer.Layers.Add(aviLyr); ////_canvas.PrimaryDrawObject = drawings[0]; ////_canvas.CurrentEnvelope = drawings[0].OriginalEnvelope; ////for (int i = 0; i < drawings.Length; i++) //// drawings[i].StartLoading((t, p) => { Text = p.ToString() + "/" + t.ToString(); }); //_canvas.Refresh(enumRefreshType.All); }
private unsafe void DrawContourLine(IRasterDataProvider prd, ContourLine[] cLines) { if (cLines == null || cLines.Length == 0) { return; } IOverviewGenerator gen = prd as IOverviewGenerator; Size size = gen.ComputeSize(1000); size = new System.Drawing.Size(prd.Width, prd.Height); Bitmap bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb); float scaleX = size.Width / (float)prd.Width; float scaleY = size.Height / (float)prd.Height; gen.Generate(new int[] { 1, 1, 1 }, ref bitmap); // using (Graphics g = Graphics.FromImage(bitmap)) { //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; foreach (ContourLine cLine in cLines) { if (cLine == null || cLine.Count < 2) { continue; } //fixed (PointF* ptr0 = cLine.Points.ToArray()) //{ // PointF* ptr = ptr0; // for (int i = 0; i < cLine.Points.Count; i++, ptr++) // { // ptr->X = ptr->X * scaleX; // ptr->Y = ptr->Y * scaleY; // } //} if ((byte)cLine.ContourValue == 100) { g.DrawCurve(Pens.Yellow, cLine.Points.ToArray()); } else { g.DrawCurve(Pens.Red, cLine.Points.ToArray()); } } } // bitmap.Save("f:\\1.bmp", ImageFormat.Bmp); }
private static BitmapObject[] GetBitmapObjects(string[] fnames, int maxSize, ICanvas canvas, out Size bmpSize, out Size dataSize, out GeoDo.RSS.Core.DrawEngine.CoordEnvelope viewPrjEvp, out GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp, out float resolution) { bmpSize = Size.Empty; dataSize = new Size(); viewPrjEvp = null; viewGeoEvp = null; resolution = 0; List <BitmapObject> bmpObjs = new List <BitmapObject>(); BitmapObject bmpO; GeoDo.RSS.Core.DrawEngine.CoordEnvelope drawEvp = null; bool isFirst = true; foreach (string fname in fnames) { if (!File.Exists(fname)) { continue; } using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider) { IOverviewGenerator ov = prd as IOverviewGenerator; bmpSize = ov.ComputeSize(maxSize); Bitmap bmp = new Bitmap(bmpSize.Width, bmpSize.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); RasterIdentify identify = new RasterIdentify(fname); object[] sts = GetColorTableFunc(prd, identify.ProductIdentify, identify.SubProductIdentify); if (sts != null) { ov.Generate(new int[] { 1, 1, 1 }, sts, ref bmp); } else { int[] bands = prd.GetDefaultBands(); if (bands == null || bands.Length == 0) { return(null); } ov.Generate(bands, ref bmp); } drawEvp = GetDrawingEnvelop(canvas, prd); if (isFirst) { viewPrjEvp = drawEvp; ICoordinateTransform tans = canvas.CoordTransform; viewGeoEvp = PrjToGeoCoordEvp(viewPrjEvp, tans); resolution = prd.ResolutionX; dataSize = GetMaxDataSize(canvas, viewPrjEvp, prd, out viewGeoEvp); isFirst = false; } else { viewPrjEvp = viewPrjEvp.Union(drawEvp); dataSize = GetMaxDataSize(canvas, viewPrjEvp, prd, out viewGeoEvp); //如果分辩率不相等则取最大的分辨率 if (resolution < prd.ResolutionX) { resolution = prd.ResolutionX; } } bmpO = new BitmapObject(bmp, drawEvp); bmpObjs.Add(bmpO); } } return(bmpObjs.Count != 0 ? bmpObjs.ToArray() : null); }