Link to home
Start Free TrialLog in
Avatar of restabro
restabroFlag for United States of America

asked on

Creating a jpeg or gif from a windows graphics form

My program uses input data to create a graph using the graphics class with a dialog box. I would like to be able to save the graph in a format that can be pasted into other applications such as Word. To do this, the graph would have to be converted into a standard format such as jpeg or gif. Sample coding of how to do this would be most appreciated. The graph is built using basic graphics methods such as"DrawLine", "DrawString", and "FillRectangle".

Most standard graphics applications such as powerpoint have file conversion options ("save as type:") as part of the "Save As" dialog. How would I access and use this feature?

Avatar of mahesh1402
mahesh1402
Flag of India image

You are using VC++ or VC++.NET ?

Using GDI+ its easy task.. Refer Image::Save methods...

Refer example code on this page :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusreference/classes/graphicsclass/graphicsmethods/save.asp

MAHESH
Avatar of restabro

ASKER

I am using VC++.NET

I think the example your showed me is a way to save the graphic image on the stack so it can be recalled later for use in the same program. I didn't see anything in the exmaple that would save the graphic as a .jpg or a .gif file.

I am looking for something similar to the System::Drawing::Printing namespace, that provides properties and methods that bring up a standard Windows dialog box for saving a file, with an option to select the file format. Again, similar to the file "Save As" function you get with Powerpoint.

Oops sorry its my mistake I suggested you to Refer Image::Save method and I by mistake post you link for Graphics::Save method.....

Image::Save :-

http://msdn.microsoft.com/library/en-us/gdicpp/GDIPlus/GDIPlusreference/classes/imageclass/imagemethods/imagesavemethods.asp <== REFER THIS

Refer example code on above link.

MAHESH
REFER This with Source Code :

Using the .NET Image Class
http://www.codeguru.com/columns/Kate/article.php/c4839/ <======



MAHESH
This is getting a lot closer to what I'm looking for. However, the examples both start with an image, modify it, then save the image as a jpeg, or another format. Will this same methodology work if there is no image to start with? In other words, I want to create the image from scratch using the DrawLine, DrawString, FillRectangle, etc., and then save the image I created from scratch to a jpeg.

Is there no way to access a standard Windows dialog box that contains the file browsing feature and File Type, again, like you find in Powerpoint? Is there anyway to use the System::Windows::Forms::SaveFileDialog class, or something similar to do this?

ASKER CERTIFIED SOLUTION
Avatar of mahesh1402
mahesh1402
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial