将已编辑的图像另存为.Jpg文件 [英] Saving the Edited image as .Jpg in a File

查看:85
本文介绍了将已编辑的图像另存为.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

推荐答案

看看下面的文章,可能会有所帮助.它不能直接解决您的问题.
http://wrb.home.xs4all.nl/Articles_2010/Article_WPFBitmapConverter_01.htm [ ^ ]
Take a look at the following article, it might help. Its not covering your issue directly.
http://wrb.home.xs4all.nl/Articles_2010/Article_WPFBitmapConverter_01.htm[^]


看这篇文章,这可能会解决您的问题:

http://www.switchonthecode.com/tutorials/csharp-tutorial-图像编辑节省裁切和调整大小 [ ^ ]
Take a look at this article, This might solve your problem:

http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing[^]


看看下面的代码.这可能对您有所帮助:
have look at the following code .This might help u:
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文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆