Exemplo n.º 1
0
        public static RectangleF GetImageFrameForNewImageLayer(ImageView image, RectangleF layerHandlerFrame)
        {
            Rect imageSize = new Rect ();
            float spacing = 10f;
            image.GetDrawingRect (imageSize);

            // Get the image dimension ratio
            float imageRatio =
                imageSize.Width () > imageSize.Height () ?
                    imageSize.Width () / imageSize.Height () :
                    imageSize.Height () / imageSize.Width ();

            // Get the image view size
            float imageViewSize =
                layerHandlerFrame.Width > layerHandlerFrame.Height ?
                    layerHandlerFrame.Height - (spacing * 8f) :
                    layerHandlerFrame.Width - (spacing * 8f);

            float displayWidth =
                imageSize.Width () > imageSize.Height () ?
                    imageViewSize :
                    imageViewSize / imageRatio;
            float displayHeight =
                imageSize.Height () > imageSize.Width () ?
                    imageViewSize :
                    imageViewSize / imageRatio;

            return new RectangleF (spacing * 4f,
                                  spacing * 4f,
                                  displayWidth,
                                  displayHeight);
        }