Exemple #1
0
        private Image ReadImage(MapImage mapImage, Point startPoint, Point endPoint, int overview)
        {
            imageStartPoint = ScreenToImage(mapImage, startPoint);
            imageEndPoint   = ScreenToImage(mapImage, endPoint);

            if (imageEndPoint.X > mapImage.ImageWidth)
            {
                imageEndPoint.X = mapImage.ImageWidth;
            }

            if (imageEndPoint.Y > mapImage.ImageHeight)
            {
                imageEndPoint.Y = mapImage.ImageHeight;
            }

            System.Drawing.Bitmap bitmap = gdalReader.GetBitmap((int)imageStartPoint.X, (int)imageStartPoint.Y,
                                                                (int)imageEndPoint.X, (int)imageEndPoint.Y, overview);

            Image image = new Image();

            image.Source = ImageControl.BitmapToBitmapImage(bitmap, mapImage.ImageFormat);
            return(image);
        }
Exemple #2
0
        private void SetImage(MapImage mapImage)
        {
            System.Drawing.Bitmap bitmap = gdalReader.GetBitmap(0, 0, mapImage.ImageWidth, mapImage.ImageHeight, 5);
            Image image = new Image();

            image.Source  = ImageControl.BitmapToBitmapImage(bitmap, mapImage.ImageFormat);
            image.Width   = mapImage.ViewWidth;
            image.Height  = mapImage.ViewHeight;
            image.Stretch = Stretch.Fill;

            if (mapImage.ImageBoundary != null)
            {
                Canvas.SetLeft(image, mapImage.ImageBoundary.Left);
                Canvas.SetTop(image, mapImage.ImageBoundary.Top);
            }
            else
            {
                Canvas.SetLeft(image, 0);
                Canvas.SetTop(image, 0);
            }

            CanvasView.Children.Add(image);
        }