コード例 #1
0
ファイル: BitmapHandler.cs プロジェクト: nzysoft/Eto
        public void Create(Image image, int width, int height, ImageInterpolation interpolation)
        {
            var source      = image.ToSD();
            var hasAlpha    = (source.Flags & (int)sdi.ImageFlags.HasAlpha) != 0;
            var pixelFormat = source.PixelFormat;

            if (
                pixelFormat == sdi.PixelFormat.Indexed ||
                pixelFormat == sdi.PixelFormat.Format1bppIndexed ||
                pixelFormat == sdi.PixelFormat.Format4bppIndexed ||
                pixelFormat == sdi.PixelFormat.Format8bppIndexed)
            {
                pixelFormat = hasAlpha ? sdi.PixelFormat.Format32bppArgb : sdi.PixelFormat.Format32bppRgb;
            }
            Control = new sd.Bitmap(width, height, pixelFormat);

            using (var graphics = sd.Graphics.FromImage(Control))
            {
                graphics.InterpolationMode = interpolation.ToSD();
                var rect = new sd.Rectangle(0, 0, width, height);
                if (hasAlpha)
                {
                    graphics.Clear(sd.Color.Transparent);
                }
                graphics.DrawImage(source, rect);
            }
        }
コード例 #2
0
        public void Create(Image image, int width, int height, ImageInterpolation interpolation)
        {
            var source = image.ToSD();

            Control = new SD.Bitmap(width, height, source.PixelFormat);
            using (var graphics = SD.Graphics.FromImage(Control)) {
                graphics.InterpolationMode = interpolation.ToSD();
                var rect = new SD.Rectangle(0, 0, width, height);
                graphics.FillRectangle(SD.Brushes.Transparent, rect);
                graphics.DrawImage(source, rect);
            }
        }
コード例 #3
0
ファイル: BitmapHandler.cs プロジェクト: landytest/Eto
        public void Create(Image image, int width, int height, ImageInterpolation interpolation)
        {
            var source      = image.ToSD();
            var pixelFormat = source.PixelFormat;

            if (
                pixelFormat == SD.Imaging.PixelFormat.Indexed ||
                pixelFormat == SD.Imaging.PixelFormat.Format1bppIndexed ||
                pixelFormat == SD.Imaging.PixelFormat.Format4bppIndexed ||
                pixelFormat == SD.Imaging.PixelFormat.Format8bppIndexed)
            {
                pixelFormat = SD.Imaging.PixelFormat.Format32bppRgb;
            }
            Control = new SD.Bitmap(width, height, pixelFormat);
            using (var graphics = SD.Graphics.FromImage(Control))
            {
                graphics.InterpolationMode = interpolation.ToSD();
                var rect = new SD.Rectangle(0, 0, width, height);
                graphics.FillRectangle(SD.Brushes.Transparent, rect);
                graphics.DrawImage(source, rect);
            }
        }