本文介绍了将已编辑的图像另存为.Jpg文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将已编辑的图像另存为.Jpg格式的文件.但是我被困住了,请帮助我.

我在WPF窗口的列表框中有图像,当我单击图像时,图像将显示在WPF Mediaelement中.现在,我想编辑图像,例如在图像上绘制一些椭圆和矩形,然后通过单击保存按钮保存图像.编辑后的图像应保存在文件中.

我的代码:

Hi,

I want to save the Edited image as .Jpg format in a file. But i got stuck up, plz help me out.

I have images in a listbox in WPF window , when i click on image the image will be displayed in the WPF Mediaelement. Now i want to edit the image like draw some ellipse and rectangles on the image and save the image by clicking on save button. The edited image should save in a file.

MY Code:

using System.Drawing

int count=0;

string filename = selectedimage; // selected image path
count=count+1;
string destPath = @"E:\Exportedimages\"+count+".jpg"; //destination folder where edited images save

Image image=Image.FromFile(filename);
image.Save(destPath);



编辑后的图像应以1.jpg,2.jpg等名称保存在目标文件夹中.

请给我任何想法.

感谢



The edited images should save with the names 1.jpg, 2.jpg etc in the destination folder.

Plz give me any ideas.

Thanks

推荐答案



string file=oHttpPostedFile.FileName;
Bitmap bitmap = new Bitmap(file);
Graphics graphics = null;
graphics = Graphics.FromImage(bitmap);
graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.InterpolationMode =                  InterpolationMode.HighQualityBicubic;
Bitmap bit = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "images/xyz");
int imgHeight = bitmap.Height;
int imgWidth = bitmap.Width;

graphics.DrawImage(bit, new Rectangle(imgWidth - 300, imgHeight - 160, 500, 77), 0, 0, 500, 77, GraphicsUnit.Pixel);
graphics.Dispose();
string file = AppDomain.CurrentDomain.BaseDirectory + "/Resources/NewImages/";
bitmap.Save(file + fileUpload1.FileName);


这篇关于将已编辑的图像另存为.Jpg文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 07:34