Ceiling() public static method

Converts a PointF to a Point by performing a ceiling operation on all the coordinates.
public static Ceiling ( PointF value ) : Point
value PointF
return Point
Example #1
0
        /// <summary>
        /// Renders the layer
        /// </summary>
        /// <param name="g">Graphics object reference</param>
        /// <param name="map">Map which is rendered</param>
        public override void Render(Graphics g, MapViewport map)
        {
            if (map.Center == null)
            {
                throw (new ApplicationException("Cannot render map. View center not specified"));
            }

            if (_image == null)
            {
                throw new Exception("Image not set");
            }


            // View to render
            var mapView = map.Envelope;

            // Layer view
            var lyrView = _envelope;

            // Get the view intersection
            var vi = mapView.Intersection(lyrView);

            if (!vi.IsNull)
            {
                // Image part
// ReSharper disable InconsistentNaming
                var imgLT   = Clip(_worldFile.ToRaster(new Coordinate(vi.MinX, vi.MaxY)));
                var imgRB   = Clip(_worldFile.ToRaster(new Coordinate(vi.MaxX, vi.MinY)));
                var imgRect = new Rectangle(imgLT, PointDiff(imgLT, imgRB, 1));

                // Map Part
                var mapLT   = Point.Truncate(map.WorldToImage(new Coordinate(vi.MinX, vi.MaxY)));
                var mapRB   = Point.Ceiling(map.WorldToImage(new Coordinate(vi.MaxX, vi.MinY)));
                var mapRect = new Rectangle(mapLT, PointDiff(mapLT, mapRB, 1));
// ReSharper restore InconsistentNaming

                // Set the interpolation mode
                var tmpInterpolationMode = g.InterpolationMode;
                g.InterpolationMode = InterpolationMode;

                // Render the image
                using (var ia = new ImageAttributes())
                {
                    ia.SetColorMatrix(new ColorMatrix {
                        Matrix44 = 1 - Transparency
                    },
                                      ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                    g.DrawImage(_image, mapRect, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
                                GraphicsUnit.Pixel, ia);
                }

                // reset the interpolation mode
                g.InterpolationMode = tmpInterpolationMode;
            }

            // Obsolete (and will cause infinite loop)
            //base.Render(g, map);
        }
Example #2
0
        /// <summary>
        /// Renders the layer
        /// </summary>
        /// <param name="g">Graphics object reference</param>
        /// <param name="map">Map which is rendered</param>
        public override void Render(Graphics g, Map map)
        {
            if (map.Center == null)
            {
                throw (new ApplicationException("Cannot render map. View center not specified"));
            }

            if (_image == null)
            {
                throw new Exception("Image not set");
            }

            // Style enabled?
            var doRender = Style.Enabled;

            // Valid for this zoom
            if (map.Zoom < Style.MinVisible || Style.MaxVisible < map.Zoom)
            {
                doRender = false;
            }

            // View to render
            var mapView = map.Envelope;

            // Layer view
            var lyrView = _envelope;

            // Get the view intersection
            var vi = mapView.Intersection(lyrView);

            //

            if (doRender && !vi.IsNull)
            {
                // Image part
// ReSharper disable InconsistentNaming
                var imgLT = Clip(Point.Truncate(new Point((int)vi.MinX, (int)vi.MaxY)), map.PixelSize);
                var imgRB = Clip(Point.Ceiling(new Point((int)vi.MaxX, (int)vi.MinY)), map.PixelSize);

                var imgRect = new Rectangle(imgLT, PointDiff(imgLT, imgRB, 1));

                // Map Part
                var mapLT   = Point.Truncate(map.WorldToImage(new Coordinate(vi.MinX, vi.MaxY)));
                var mapRB   = Point.Ceiling(map.WorldToImage(new Coordinate(vi.MaxX, vi.MinY)));
                var mapRect = new Rectangle(mapLT, PointDiff(mapLT, mapRB, 1));
// ReSharper restore InconsistentNaming

                // Set the interpolation mode
                var tmpInterpolationMode = g.InterpolationMode;
                g.InterpolationMode = InterpolationMode;

                // Render the image
                using (var ia = new ImageAttributes())
                {
                    ia.SetColorMatrix(new ColorMatrix {
                        Matrix44 = 1 - Transparency
                    },
                                      ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                    g.DrawImage(_image, mapRect, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
                                GraphicsUnit.Pixel, ia);
                }

                // reset the interpolation mode
                g.InterpolationMode = tmpInterpolationMode;
            }

            base.Render(g, map);
        }