IT Community - Software Programming, Web Development and Technical Support

Converting image from one format to another in C#

This is a discussion on Converting image from one format to another in C# within the C# Programming forums, part of the Software Development category; Hi Sathish, Thanks.This code seems to be very simple and perfect.I would say that this is apt to ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #21 (permalink)  
Old 03-10-2008, 12:28 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Thumbs up Re: Converting image from one format to another in C#

Hi Sathish,
Thanks.This code seems to be very simple and perfect.I would say that this is apt to my requirement.Thank u very much.It works good
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 03-10-2008, 12:42 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Exclamation Re: Converting image from one format to another in C#

Hi,
Does anybody know how to convert an image to gray scale image?Any help thanks
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23 (permalink)  
Old 03-10-2008, 12:46 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Thumbs up Re: Converting image from one format to another in C#

Hi,
You can use the following code to convert the image to gray-scale image

Code:
public bool GrayScale(Bitmap b)
		{
			// GDI+ still lies to us - the return format is BGR, NOT RGB. 
			BitmapData bmData = b.LockBits(new Rectangle(0,0, b.Width, b.Height), 
				ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); 
			int stride = bmData.Stride; //the length of the line
			System.IntPtr Scan0 = bmData.Scan0; 

			unsafe
			{
				byte * p = (byte*)(void*)Scan0;

				int nOffset =  stride - b.Width*3;

				byte red, green, blue;

				for(int y=0;y < b.Height;++y)
				{
					for(int x=0; x < b.Width; ++x )
					{
						blue = p[0];
						green = p[1];
						red = p[2];

						p[0] = p[1] = p[2] = (byte)(.299 * red 
							+ .587 * green 
							+ .114 * blue);

						p += 3;
					}
					p += nOffset;
				}
			}		
			
			b.UnlockBits(bmData);

			return true;
		}
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24 (permalink)  
Old 03-25-2008, 03:56 AM
risefei risefei is offline
D-Web Trainee
 
Join Date: Mar 2008
Posts: 5
risefei is on a distinguished road
Default Re: Converting image from one format to another in C#

Does anybody know how to convert a svg to an image? For exampleng.
Thanks a lot ^-^
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25 (permalink)  
Old 06-04-2008, 01:06 AM
getzephyr getzephyr is offline
D-Web Programmer
 
Join Date: Dec 2007
Posts: 53
getzephyr is on a distinguished road
Default Re: Converting image from one format to another in C#

While browsing I came across this tool named Advanced Batch Converter, hope it could be useful to you.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-programming/5233-converting-image-one-format-another-c.html
Posted By For Type Date
DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 02-12-2008 09:41 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert image to other image format using CODEC in .NET 3.0 Mramesh C# Programming 0 02-07-2008 02:33 AM
Converting a generics List<T> to string[] oxygen C# Programming 4 12-21-2007 02:34 AM
How to convert jpg, bmp, tif,... image formats in to another format using c# .Net? Archer C# Programming 1 09-07-2007 07:23 AM
Converting Nikon camera RAW images to JPEG,TIFF files using Adobe dll in C#.NET oxygen C# Programming 5 08-16-2007 02:26 AM
Better Image Format Joe Web Design Help 12 03-06-2007 10:31 PM


All times are GMT -7. The time now is 10:45 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0