Making gif tiff and png multi frame pictures

aewarnick

Well-known member
Joined
Jan 29, 2003
Messages
1,031
I have looked all over the net for information on how to make those three types of multi page pictures but the only thing I found was a snippet about creating tiff files and it does not even work. Here is the code for making tiff files that produces the error after the code
C#:
ImageCodecInfo[] iciArr= ImageCodecInfo.GetImageEncoders();
			int n=0;
			while(iciArr[n].MimeType != "image/tiff")
				n++;

			Bitmap[]B=new Bitmap[this.bitmapArrList.Count];
			for(int i=0; i < this.bitmapArrList.Count; i++)
				B[i]=(Bitmap)this.bitmapArrList[i];

			EncoderParameters encPs=new EncoderParameters(1);
			encPs.Param[0]=new EncoderParameter(Encoder.SaveFlag, (int)EncoderValue.MultiFrame);
			
			Stream F=new FileStream("D:\\pic.tif", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
			B[0].Save(F, iciArr[n], encPs);
			F.Close();

			encPs.Param[0]= new EncoderParameter(Encoder.SaveFlag, (long)EncoderValue.FrameDimensionPage);

			for(int i=0; i < this.bitmapArrList.Count; i++)
			{
				try{
					//((Bitmap)this.bitmapArrList[i]).Save("D:\\pic"+i+".tif", ImageFormat.Tiff);
					B[0].SaveAdd(B[i], encPs);
				}
				catch(Exception ex) { MessageBox.Show(ex+""); }
			}

			try{
				encPs.Param[0]= new EncoderParameter(Encoder.SaveFlag, (long)EncoderValue.Flush);
				B[0].SaveAdd(encPs);
			}
			catch(Exception ex) { MessageBox.Show(ex+""); }
Error:
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Image.SaveAdd(Image image, EncoderParameters encoderParams)

If anyone knows good documentation on how to create multi page files that would be most helpful.
 
I am interested in this too. Specifically for GIFs. I cannot find any source of internal (that I can understand) formats for animated Gif.
 
Back
Top