Exemple #1
0
        private Size GetScaledImageSize(ImageSize baseSize)
        {
            Size imageSize;
            Size scaledImageSize;

            if (baseSize == PostHtmlEditing.ImageSize.Original)
            {
                imageSize       = GetFullImageSizeWithRotation();
                scaledImageSize = imageSize;
            }
            else
            {
                imageSize = ImageSizeHelper.GetSizeConstraints(ConvertToImageSizeName(baseSize));

                //if the image is rotated, so create a scaled size based on the rotation within the size bounds
                if (ImageUtils.IsRotated90(_rotation))
                {
                    scaledImageSize = ImageUtils.GetScaledImageSize(imageSize.Height, imageSize.Width, _fullImageSize);
                    scaledImageSize = new Size(scaledImageSize.Height, scaledImageSize.Width);
                }
                else
                {
                    scaledImageSize = ImageUtils.GetScaledImageSize(imageSize.Width, imageSize.Height, _fullImageSize);
                }
            }
            return(scaledImageSize);
        }
Exemple #2
0
        /// <summary>
        /// Scales the given imageSourceSize to the imageSizeName constraints.
        /// </summary>
        public static Size ScaleImageSizeName(ImageSizeName imageSizeName, Size imageSourceSize, RotateFlipType currentRotation)
        {
            Debug.Assert(imageSizeName != ImageSizeName.Custom, "No scaling policy associated with ImageSizeName.Custom");

            Size scaledImageSize = imageSourceSize;

            if (imageSizeName != ImageSizeName.Full)
            {
                Size sizeConstraints = ImageSizeHelper.GetSizeConstraints(imageSizeName);

                if (ImageUtils.IsRotated90(currentRotation))
                {
                    scaledImageSize = ImageUtils.GetScaledImageSize(sizeConstraints.Height, sizeConstraints.Width, imageSourceSize);
                    scaledImageSize = new Size(scaledImageSize.Height, scaledImageSize.Width);
                }
                else
                {
                    scaledImageSize = ImageUtils.GetScaledImageSize(sizeConstraints.Width, sizeConstraints.Height, imageSourceSize);
                }
            }

            return(scaledImageSize);
        }
Exemple #3
0
        private bool ImageSizeNameMatches(ImageSizeName sizeName, Size orginalSize, Size currentSize)
        {
            Size constrainedSize = ImageSizeHelper.GetSizeConstraints(sizeName);

            return(currentSize == ImageUtils.GetScaledImageSize(constrainedSize.Width, constrainedSize.Height, orginalSize));
        }