Click here to Skip to main content
15,886,693 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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);


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

Plz give me any ideas.

Thanks
Posted
Updated 14-Oct-11 1:19am
v9

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[^]
 
Share this answer
 
Comments
RaviRanjanKr 13-Oct-11 4:33am    
Nice Link Vivek, My 5+
Vivek Krishnamurthy 13-Oct-11 5:08am    
Thanks
 
Share this answer
 
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);
 
Share this answer
 
v5
Comments
KiranBabu M 14-Oct-11 7:16am    
same image is saving but iam not able to save the edited image..
member60 15-Oct-11 0:47am    
in the avove code: in original image(ie.assigned to bitmap) an existing image 'xyz' from images folder is inserted and saved in NewImages folder .plz check once properly this code has worked for me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900