Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How would you save an image array to a file in C#?

I created an image array as follows in C# using VS2010:

Image[] newImage = new Image[1000];

How can I save this image array to a file titled "L:\\F\\Source\\test1.tiff"
Avatar of Ronald Buster
Ronald Buster
Flag of Netherlands image

I don't know what you are doing because you have an array of images limited to 1000

You can save all the images in the array with :

foreach ( Image image in newImage )
{
   image.Save("L:\\F\\Source\\test1.tiff", System.Drawing.Imaging.ImageFormat.Tiff);
}

However this is not intended or is it.
Avatar of it_saige
Assuming that you meant that you have a byte array that you want to write to disk:
using System.Drawing;
using System.IO;

namespace EE_Q28711066
{
	class Program
	{
		static void Main(string[] args)
		{
			byte[] array = new byte[1000];
			using (MemoryStream ms = new MemoryStream(array))
			{
				Image image = Image.FromStream(ms);
				image.Save("EE_Q28711066.TIFF", System.Drawing.Imaging.ImageFormat.Tiff);
			}
		}
	}
}

Open in new window

Otherwise, if you do in fact have an image array (that is an array of images), then you would either.  Write each image to it's own file (using the method above) or combine the images into one file.

-saige-
ASKER CERTIFIED SOLUTION
Avatar of Snarf0001
Snarf0001
Flag of Canada 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