473,396 Members | 1,722 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,396 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 4764

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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.