Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
how to save image and pdf formet in SaveFileDialog?
public static bool SaveDIBAs( string picname, IntPtr bminfo, IntPtr pixdat )
		{
		SaveFileDialog sd = new SaveFileDialog();
 
		sd.FileName = picname;
		sd.Title = "Save bitmap as...";
		sd.Filter = "Bitmap file (*.bmp)|*.bmp|TIFF file (*.tif)|*.tif|JPEG file (*.jpg)|*.jpg|PNG file (*.png)|*.png|GIF file (*.gif)|*.gif|All files (*.*)|*.*";
		sd.FilterIndex = 1;
		if( sd.ShowDialog() != DialogResult.OK )
			return false;
 
		Guid clsid;
		if( ! GetCodecClsid( sd.FileName, out clsid ) )
			{
			MessageBox.Show( "Unknown picture format for extension " + Path.GetExtension( sd.FileName ),
							"Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information );
			return false;
			}
		
		IntPtr img = IntPtr.Zero;
		int st = GdipCreateBitmapFromGdiDib( bminfo, pixdat, ref img );
		if( (st != 0) || (img == IntPtr.Zero) )
			return false;
 
		st = GdipSaveImageToFile( img, sd.FileName, ref clsid, IntPtr.Zero );
		GdipDisposeImage( img );
		return st == 0;
		}
Posted 1-Apr-13 19:52pm
Edited 1-Apr-13 22:54pm
ridoy52K
v2
Comments
Sergey Alexandrovich Kryukov at 2-Apr-13 1:37am
   
What is "formet"?
File dialog boxes do not save anything, they are used to require a file name and obtain it from the user.
—SA
minu1989 at 2-Apr-13 2:26am
   
yes, i agree with you.I want to save file in different formet like pdf,doc,Image)bmp,tiff,jpg,png)etc in c# win-form.
Sergey Alexandrovich Kryukov at 2-Apr-13 2:29am
   
OK, save it. What's the problem? Creation of the content is the problem, to be considered separately for each format, a bit too much for a single question...
—SA
ThePhantomUpvoter at 2-Apr-13 1:39am
   
Why don't you just add PDF to your filter?
minu1989 at 2-Apr-13 2:23am
   
A added pdf in filter. when i save file as image formet like bmp,TIFF,JPEG,PNG,GIF,gif save them, but in pdf formet it gives error.
Sergey Alexandrovich Kryukov at 2-Apr-13 2:30am
   
Do we have to pull all the detail from you? What error..?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

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

  Print Answers RSS
0 OriginalGriff 285
1 DamithSL 265
2 CPallini 195
3 Maciej Los 175
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100