Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying multipage tiff file in ReportViewer

Status
Not open for further replies.

yonelay

Programmer
Jan 17, 2007
10
US
Hi,

I converted my tiff file to gif in each frame so that I can view tiff image in the reportviewer. I am able to display the image, but it only shows one frame. If there are multiple frames in tiff file, it shows the last one. How can I modify my code so that all the frames displayed?

private void btnViewReport_Click(object sender, EventArgs e)
{
string imagePathName= string.Empty;

DataRow dr;
DataSet reportDs = prGetClientEmplListDataSet.Clone();

foreach (DataRowView item in nameList.CheckedItems)
{
dr = reportDs.Tables[0].NewRow();
dr.ItemArray = item.Row.ItemArray;

//assign image path
imagePathName = dr["last_name"] + "_" + dr["first_name"] + ".tif";

if (File.Exists(imagePathName))
{
System.Drawing.Image imageFile;
imageFile = System.Drawing.Image.FromFile(imagePathName);
System.Drawing.Imaging.FrameDimension frameDimensions = new System.Drawing.Imaging.FrameDimension(imageFile.FrameDimensionsList[0]);
int NumberOfFrames = imageFile.GetFrameCount(frameDimensions);
string[] paths = new string[NumberOfFrames];
for (int intFrame = 0; intFrame < NumberOfFrames; ++intFrame)
{
imageFile.SelectActiveFrame(frameDimensions, intFrame);
Bitmap bmp = new Bitmap(imageFile);
paths[intFrame] = imagePathName.Remove(imagePathName.Length - 4, 4) + intFrame.ToString() + ".gif";

bmp.Save(paths[intFrame], System.Drawing.Imaging.ImageFormat.Gif);
bmp.Dispose();
}
imageFile.Dispose();

foreach (string strPath in paths)
{
//This is where my problem is. When I have more than two frames in tiff. It only shows the last frame, but I need to show all the frame. The following code needs to assign in array or something, but I don't know how.

dr["fileDisplayName"] = @"File:\\\" + strPath;
}
}
else
{
dr["fileDisplayName"] = @"File:\\\c:\imagenotfound.gif";
}

reportDs.Tables[0].Rows.Add(dr);
}

ViewReport report = new ViewReport();
report.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(
"prGetClientEmplListDataSet_prGetClientEmployeeList", reportDs.Tables[0]));
report.ShowDialog();

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top