System.Drawing.Bitmap.SetImageInformation C# (CSharp) Method

SetImageInformation() private method

private SetImageInformation ( int frame ) : void
frame int
return void
        private void SetImageInformation(int frame)
        {
            var imageSource = CGImageSource.FromDataProvider (dataProvider);

            frameCount = (int)imageSource.ImageCount;

            var properties = imageSource.GetProperties (frame, null);

            // This needs to be incorporated in frame information later
            // as well as during the clone methods.
            dpiWidth =  properties.DPIWidthF != null ? (float)properties.DPIWidthF : ConversionHelpers.MS_DPI;
            dpiHeight = properties.DPIWidthF != null ? (float)properties.DPIHeightF : ConversionHelpers.MS_DPI;
            physicalDimension.Width = (float)properties.PixelWidth;
            physicalDimension.Height = (float)properties.PixelHeight;

            // The physical size may be off on certain implementations.  For instance the dpiWidth and dpiHeight
            // are read using integers in core graphics but in windows it is a float.
            // For example:
            // coregraphics dpiWidth = 24 as integer
            // windows dpiWidth = 24.999935 as float
            // this gives a few pixels difference when calculating the physical size.
            // 256 * 96 / 24 = 1024
            // 256 * 96 / 24.999935 = 983.04
            //
            // https://bugzilla.xamarin.com/show_bug.cgi?id=14365
            // PR: https://github.com/mono/maccore/pull/57
            //

            physicalSize = new SizeF (physicalDimension.Width, physicalDimension.Height);
            physicalSize.Width *= ConversionHelpers.MS_DPI / dpiWidth;
            physicalSize.Height *= ConversionHelpers.MS_DPI / dpiHeight;

            // Set the raw image format
            // We will use the UTI from the image source
            switch (imageSource.TypeIdentifier)
            {
            case "public.png":
                rawFormat = ImageFormat.Png;
                break;
            case "com.microsoft.bmp":
                rawFormat = ImageFormat.Bmp;
                break;
            case "com.compuserve.gif":
                rawFormat = ImageFormat.Gif;
                break;
            case "public.jpeg":
                rawFormat = ImageFormat.Jpeg;
                break;
            case "public.tiff":
                rawFormat = ImageFormat.Tiff;
                break;
            case "com.microsoft.ico":
                rawFormat = ImageFormat.Icon;
                break;
            case "com.adobe.pdf":
                rawFormat = ImageFormat.Wmf;
                break;
            default:
                rawFormat = ImageFormat.Png;
                break;
            }
        }