简体   繁体   中英

How to get the imagestream from graphics class

I want to save the image created from graphics class how to do it? (if i can get the imagestream then i can do it using below code)

    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);

I believe that img gets modified with everything you did to the g that got created from it. So you should be able to call img.Save() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM