示例#1
0
        public void DrawPreview(Graphics vGraphics, Rectangle vImageRect, float pPreviewZoom)
        {
            var vCenter33         = PositionUtm32.Transform(33);
            var vOrigoUtm33       = vCenter33.Move(-vImageRect.Width / 2.0 / Setup.PixelsPerMeter * pPreviewZoom, vImageRect.Height / 2.0 / Setup.PixelsPerMeter * pPreviewZoom);
            var vBottomRightUtm33 = vCenter33.Move(vImageRect.Width / 2.0 / Setup.PixelsPerMeter * pPreviewZoom, -vImageRect.Height / 2.0 / Setup.PixelsPerMeter * pPreviewZoom);

            var vBounds = new UtmBounds(
                vOrigoUtm33, vBottomRightUtm33
                );

            var vTask = DownloadAllImagesAsync(vBounds);

            DrawMap(vGraphics, pPreviewZoom, vBounds);

            vGraphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            vGraphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            vGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            SizeF vLabelRectSizeUtm     = new SizeF(30F, 20F);
            SizeF vLabelRectSizeLatLong = new SizeF(40F, 20F);

            if (Setup.ShowUtmGrid)
            {
                DrawUtmGrid(vGraphics, vOrigoUtm33, vBottomRightUtm33, pPreviewZoom, vLabelRectSizeUtm);
            }
            if (Setup.ShowLatLonGrid)
            {
                DrawLatLongGrid(vGraphics, vOrigoUtm33, vBottomRightUtm33, pPreviewZoom, vLabelRectSizeLatLong);
            }

            RectangleF vPaperRect = new RectangleF();

            vPaperRect.Size    = GetImageSize();
            vPaperRect.Width  /= (float)pPreviewZoom;
            vPaperRect.Height /= (float)pPreviewZoom;
            vPaperRect.Offset((vImageRect.Width - vPaperRect.Width) / 2F, (vImageRect.Height - vPaperRect.Height) / 2F);
            var vPaperPen = new Pen(Color.Green, 5F);

            vGraphics.DrawRectangle(vPaperPen, vPaperRect.X, vPaperRect.Y, vPaperRect.Width, vPaperRect.Height);

            if (Setup.ShowCrossHair)
            {
                DrawCrossHair(vGraphics, vCenter33, vOrigoUtm33, pPreviewZoom);
            }

            if (Setup.RadiusR25.HasValue)
            {
                DrawRadius(vGraphics, vCenter33, vOrigoUtm33, Setup.RadiusR25.Value, pPreviewZoom);
            }

            if (Setup.RadiusR50.HasValue)
            {
                DrawRadius(vGraphics, vCenter33, vOrigoUtm33, Setup.RadiusR50.Value, pPreviewZoom);
            }
        }
示例#2
0
        public async Task <Bitmap> CreateBitmapAsync(UtmBounds pBounds)
        {
            await DownloadAllImagesAsync(pBounds); // new UtmBounds(OrigoUtm33, BottomRigthUtm33));

            var vResult = await Task <Bitmap> .Run(() =>
            {
                var vImageSize               = new Size((int)((BottomRigthUtm33.Easting - OrigoUtm33.Easting + Setup.TileSizeInMeters) * Setup.PixelsPerMeter), (int)((OrigoUtm33.Northing - BottomRigthUtm33.Northing) * Setup.PixelsPerMeter)); // GetImageSize();
                Bitmap vBitmap               = new Bitmap(vImageSize.Width, vImageSize.Height);
                Graphics vGraphics           = Graphics.FromImage(vBitmap);
                vGraphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                vGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                vGraphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                DrawMap(vGraphics);
                vGraphics.Dispose();

                var vRescaledSize                    = GetImageSize();
                Bitmap vRescaledBitmap               = new Bitmap(vRescaledSize.Width, vRescaledSize.Height);
                Graphics vRescaledGraphics           = Graphics.FromImage(vRescaledBitmap);
                vRescaledGraphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                vRescaledGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                vRescaledGraphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                vRescaledGraphics.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

                var vCenterUtm33 = PositionUtm32.Transform(33);

                var vNewOrigo       = vCenterUtm33.Move(-vRescaledSize.Width / Setup.PixelsPerMeter / 2.0, vRescaledSize.Height / Setup.PixelsPerMeter / 2.0);
                var vNewBottomRight = vCenterUtm33.Move(vRescaledSize.Width / Setup.PixelsPerMeter / 2.0, -vRescaledSize.Height / Setup.PixelsPerMeter / 2.0);
                var vOffset         = Utm33ToBitmapPosition(vNewOrigo, OrigoUtm33);
                vRescaledGraphics.DrawImage(vBitmap, -vOffset.X, -vOffset.Y);
                vBitmap.Dispose();

                SizeF vLabelRectSizeUtm     = new SizeF((float)(Setup.PixelsPerMeter * 30.0 * Setup.ScaleAndTileSize.Scale / 5000.0), (float)(Setup.PixelsPerMeter * 20.0 * Setup.ScaleAndTileSize.Scale / 5000.0));
                SizeF vLabelRectSizeLatLong = new SizeF((float)(Setup.PixelsPerMeter * 40.0 * Setup.ScaleAndTileSize.Scale / 5000.0), (float)(Setup.PixelsPerMeter * 20.0 * Setup.ScaleAndTileSize.Scale / 5000.0));

                if (Setup.ShowUtmGrid)
                {
                    DrawUtmGrid(vRescaledGraphics, vNewOrigo, vNewBottomRight, 1F, vLabelRectSizeUtm);
                }
                if (Setup.ShowLatLonGrid)
                {
                    DrawLatLongGrid(vRescaledGraphics, vNewOrigo, vNewBottomRight, 1F, vLabelRectSizeLatLong);
                }

                var vNewCenter = new UtmPosition(33, vNewOrigo.Easting + (vNewBottomRight.Easting - vNewOrigo.Easting) / 2.0, vNewBottomRight.Northing + (vNewOrigo.Northing - vNewBottomRight.Northing) / 2.0);

                if (Setup.RadiusR25.HasValue)
                {
                    DrawRadius(vRescaledGraphics, vNewCenter, vNewOrigo, Setup.RadiusR25.Value, 1f);
                }
                if (Setup.RadiusR50.HasValue)
                {
                    DrawRadius(vRescaledGraphics, vNewCenter, vNewOrigo, Setup.RadiusR50.Value, 1f);
                }

                if (Setup.ShowCrossHair)
                {
                    DrawCrossHair(vRescaledGraphics, vNewCenter, vNewOrigo, 1f);
                }

                vRescaledGraphics.DrawRectangle(Pens.Black, 0f, 0f, vRescaledSize.Width - 1f, vRescaledSize.Height - 1f);

                return(vRescaledBitmap);
            });

            return(vResult);
        }