/// <summary> /// Retreives a chunk of the raster. /// </summary> /// <param name="srcX">A minimum X coordinate of the querying area</param> /// <param name="srcY">A minimum Y coordinate of the querying area</param> /// <param name="srcWidth">A width of the querying area</param> /// <param name="srcHeight">A height of the querying area</param> /// <param name="maxDestWidth">A maximum width in pixels of the resulting raster</param> /// <param name="maxDestHeight">A maximum height in pixels of the resulting raster</param> /// <param name="bounds">A bounds of querying area on the map</param> /// <param name="receiver">An object receiving raster</param> public void QueryRaster(int srcX, int srcY, int srcWidth, int srcHeight, int maxDestWidth, int maxDestHeight, BoundingRectangle bounds, IRasterReceiver receiver) { if (_bitmap == null) { throw new InvalidOperationException("Bitmap is not set"); } Bitmap result = new Bitmap(Math.Max(maxDestWidth, 1), Math.Max(maxDestHeight, 1), _bitmap.PixelFormat); using (Graphics g = Graphics.FromImage(result)) { RectangleF srcRect = new RectangleF(srcX, srcY, srcWidth, srcHeight); RectangleF destRect = new RectangleF(0, 0, maxDestWidth, maxDestHeight); g.DrawImage(_bitmap, destRect, srcRect, GraphicsUnit.Pixel); } receiver.AddRasterPreview(result, bounds, Width, Height); }
/// <summary> /// Retreives a chunk of the raster. /// </summary> /// <param name="srcX">A minimum X coordinate of the querying area</param> /// <param name="srcY">A minimum Y coordinate of the querying area</param> /// <param name="srcWidth">A width of the querying area</param> /// <param name="srcHeight">A height of the querying area</param> /// <param name="maxDestWidth">A maximum width in pixels of the resulting raster</param> /// <param name="maxDestHeight">A maximum height in pixels of the resulting raster</param> /// <param name="bounds">A bounds of querying area on the map</param> /// <param name="receiver">An object receiving raster</param> public void QueryRaster(int srcX, int srcY, int srcWidth, int srcHeight, int maxDestWidth, int maxDestHeight, BoundingRectangle bounds, IRasterReceiver receiver) { if (_bitmap == null) throw new InvalidOperationException("Bitmap is not set"); Bitmap result = new Bitmap(Math.Max(maxDestWidth, 1), Math.Max(maxDestHeight, 1), _bitmap.PixelFormat); using(Graphics g = Graphics.FromImage(result)) { RectangleF srcRect = new RectangleF(srcX, srcY, srcWidth, srcHeight); RectangleF destRect = new RectangleF(0, 0, maxDestWidth, maxDestHeight); g.DrawImage(_bitmap, destRect, srcRect, GraphicsUnit.Pixel); } receiver.AddRasterPreview(result, bounds, Width, Height); }