예제 #1
0
        /// <summary>
        /// Sets the encoded image meta data.
        /// </summary>
        public async Task ParseMetaDataAsync()
        {
            ImageFormat format = ImageFormatChecker.GetImageFormat_WrapIOException(
                GetInputStream());

            Format = format;

            // Dimensions decoding is not yet supported for WebP since
            // BitmapUtil.DecodeDimensions has a bug where it will return 100x100 for
            // some WebPs even though those are not its actual dimensions.
            if (!ImageFormatHelper.IsWebpFormat(Format))
            {
                Tuple <int, int> dimensions = await BitmapUtil
                                              .DecodeDimensionsAsync(GetInputStream())
                                              .ConfigureAwait(false);

                if (dimensions != default(Tuple <int, int>))
                {
                    Width  = dimensions.Item1;
                    Height = dimensions.Item2;

                    // Load the rotation angle only if we have the dimensions
                    if (Format == ImageFormat.JPEG)
                    {
                        if (RotationAngle == UNKNOWN_ROTATION_ANGLE)
                        {
                            RotationAngle = JfifUtil.GetAutoRotateAngleFromOrientation(
                                JfifUtil.GetOrientation(GetInputStream()));
                        }
                    }
                    else
                    {
                        RotationAngle = 0;
                    }
                }
            }
        }