如何从图形类中获取图像流

时间:2014-10-10 04:12:50

标签: c# .net graphics

我想保存从图形类创建的图像怎么做? (如果我可以获得图像流,那么我可以使用下面的代码来完成它)

    var bmp = Bitmap.FromStream(originalStream);

       // var newImage = new Bitmap(bmp.Width, bmp.Height);

        var img = new Bitmap(bmp, 
                    (int)(bmp.Size.Width / zoomLevel), 
                    (int)(bmp.Size.Height / zoomLevel));

        var g = Graphics.FromImage(img);

        g.DrawImageUnscaled(bmp, (int)CurrentX, (int)CurrentY);
        g.DrawString(Text, SystemFonts.DefaultFont, Brushes.Black, (float)CurrentTextX, (float)CurrentTextY);




        string originalImagePath = string.Concat(@"Photos/", string.Format("{0:yyyy-MM-dd}", ApplicationDateTime.Today) + "/" + Session[Keys.UserId], "/", url.Split('/').Last());
        var originalImageamazonResponse = _s3AmazonServices.StoreImage(originalStream, originalImagePath, Configuration.ConfigurationNew.Current.S3Bucket, Configuration.ConfigurationNew.Current.S3AmazonAccessKey, Configuration.ConfigurationNew.Current.S3AmazonSecretKey);

1 个答案:

答案 0 :(得分:1)

我相信img会根据您对其创建的g所做的一切进行修改。所以你应该可以致电img.Save()