Esempio n. 1
0
        internal Rectangle GetImageRectangle(float dpi)
        {
            var rect   = Rectangle.ToRectangleF();
            var mul    = dpi / 72f;
            var values = new[] { rect.X *mul, rect.Y *mul, rect.Width *mul, rect.Height *mul };

            // BUG 0015690
            for (int i = 0; i < values.Length; i++)
            {
                var v = SMath.Round(values[i]);
                if (SMath.Abs(v - values[i]) < 0.01f)
                {
                    values[i] = (float)v;
                }
            }

            int x      = (int)SMath.Floor(values[0]);
            int y      = (int)SMath.Floor(values[1]);
            int width  = (int)SMath.Ceiling(values[2]);
            int height = (int)SMath.Ceiling(values[3]);

            return(new Rectangle(x, y, width, height));
        }