示例#1
0
        // Set the dgImage field within this object.
        internal void SetDGImage(PortableImage dgImage)
        {
            flags = (int) dgImage.GetFlags();
#if !ECMA_COMPAT
            switch (dgImage.LoadFormat)
            {
                case PortableImage.Png:
                    rawFormat = ImageFormat.Png;
                    break;
                case PortableImage.Jpeg:
                    rawFormat = ImageFormat.Jpeg;
                    break;
                case PortableImage.Gif:
                    rawFormat = ImageFormat.Gif;
                    break;
                case PortableImage.Tiff:
                    rawFormat = ImageFormat.Tiff;
                    break;
                case PortableImage.Bmp:
                    rawFormat = ImageFormat.Bmp;
                    break;
                case PortableImage.Icon:
                    rawFormat = ImageFormat.Icon;
                    break;
                case PortableImage.Exif:
                    rawFormat = ImageFormat.Exif;
                    break;

                default: // Not loaded from a source?
                    rawFormat = ImageFormat.MemoryBmp;
                    break;
            }

            frameDimensionsList = new Guid [0];
            this.dgImage = dgImage;
            // If we are loading an icon, set the size of the image
            // to the size of the first icon
            if (rawFormat == ImageFormat.Icon)
            {
                width = dgImage.GetFrame(0).Width;
                height = dgImage.GetFrame(0).Height;
            }
            else
            {
                width = dgImage.Width;
                height = dgImage.Height;
            }
#else
				this.dgImage = dgImage;
				width = dgImage.GetFrame(0).Width;
				height = dgImage.GetFrame(0).Height;
#endif
            horizontalResolution = Graphics.DefaultScreenDpi;
            verticalResolution = Graphics.DefaultScreenDpi;
            pixelFormat = (PixelFormat)
                (dgImage.PixelFormat);
        }