Click here to Skip to main content
Rate this: bad
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
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.
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...
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..?

1 solution

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

Solution 1


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

  Print Answers RSS
0 OriginalGriff 520
1 Maciej Los 205
2 Suvendu Shekhar Giri 159
3 Peter Leow 140
4 Kornfeld Eliyahu Peter 133
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 8,895
2 Peter Leow 5,044
3 Kornfeld Eliyahu Peter 3,333
4 Maciej Los 2,561

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2015
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