System.Drawing.Point.Ceiling C# (CSharp) Method

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
        public static Point Ceiling(PointF value) => new Point((int)Math.Ceiling(value.X), (int)Math.Ceiling(value.Y));

Same methods

Point::Ceiling ( System value ) : System.Drawing.Point

Usage Example

Exemplo n.º 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);
        }
All Usage Examples Of System.Drawing.Point::Ceiling