473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

merge images

hi,everyone
I have a question about merging images. I want to merge serval tiff
images into one file using C#,that means the final file has multiple
frames.My problem is that I want each frame in the final file is of
single-strip,but when I want to merge serval images which has been of
singe-strip,the final file my codes produced contains images which are all
of multiple-strips. My codes is listed below:

public static bool MergeTifs(ref string mergedFile,ArrayList
fileList)
{
int counts = fileList.Count;
if (counts < 1)
{
return false;
}
try
{
EncoderParameters eps=new EncoderParameters(2);

eps.Param[0] = new

EncoderParameter(Encoder.SaveFlag,(long)EncoderVal ue.MultiFrame);
eps.Param[1] = new EncoderParameter(Encoder.Compression,
(long)EncoderValue.CompressionCCITT3);

System.Drawing.Image mergedImage =
System.Drawing.Image.FromFile((string)fileList[0]);

//Get the correct encoder from the list of available
encoders

ImageCodecInfo[] infos = ImageCodecInfo.GetImageEncoders();

int n=0;
while(infos[n].MimeType!="image/tiff")
n++;

//save the first page
System.Drawing.Image imageToAdd = null;
mergedImage.Save(mergedFile,infos[n],eps);
Bitmap firstBmp = new Bitmap((string)fileList[0]);
int first_num = firstBmp.GetFrameCount(FrameDimension.Page);
for(int j = 1; j < first_num; j++)
{
firstBmp.SelectActiveFrame(FrameDimension.Page,j);
eps.Param[0]=new
EncoderParameter(Encoder.SaveFlag,(long)EncoderVal ue.FrameDimensionPage);
mergedImage.SaveAdd(firstBmp,eps);
}
firstBmp.Dispose();
for(int i = 1; i< counts; i++)
{
string fileToAdd = (string)fileList[i];
imageToAdd = System.Drawing.Image.FromFile(fileToAdd);
int num =
imageToAdd.GetFrameCount(FrameDimension.Page);
for(int k = 0; k < num; k++)
{

imageToAdd.SelectActiveFrame(FrameDimension.Page,k );
eps.Param[0]=new
EncoderParameter(Encoder.SaveFlag,(long)EncoderVal ue.FrameDimensionPage);
mergedImage.SaveAdd(imageToAdd,eps);
}
imageToAdd.Dispose();
}
eps.Param[0]=new

EncoderParameter(Encoder.SaveFlag,(long)EncoderVal ue.Flush);
mergedImage.SaveAdd(eps);
mergedImage.Dispose();
return true;
}
catch
{
return false;
}
}

the first parameter is the file name of the final file.
Could anyone kindly help me? Thank you in advance.

Crespo

2006-07-03
Jul 4 '06 #1
0 4761

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Morris | last post by:
Does anyone know whether it is possible to effect a mail merge to MSWord using VBScript in an asp file? I know it is possible to produce a doc file and force a download using ...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
2
by: Imtiaz | last post by:
Hi, I have two JPEG Images. Now I wanted to merge them into one image. I am trying to use Image.SaveAdd to do this. But it is throwing an exception "Invalid parameter used." Following is the...
3
by: Carl Gilbert | last post by:
Hi I want to write an application that can merge two images with a bit of re-sizing and changing of opacity thrown in for good measure. I have a backdrop that can be in any format and an...
0
by: Zeeway | last post by:
hi,everyone I have a question about merging images. I want to merge serval tiff images into one file using C#,that means the final file has multiple frames.My problem is that I want each frame in...
0
by: =?Utf-8?B?Sm9uIEphY29icw==?= | last post by:
I load a bitmap from a file and display it in a PictureBox: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Fn As String =...
1
by: cristalink | last post by:
Hi, I have MS Visual Studio 2008 both Pro and Dev Team Edition SP1 installed. I've compiled a managed C++ .DLL which automatically had a manifest embedded, with the following dependency:...
5
by: madhav001 | last post by:
Hi, I am biginner in C++ and I tried to combine two memory buffers of TIFF image data to one so that to save it as one image. ie: left half image + right half image = a full image. That was not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.