Multipage TIFF to BMP image is showing empty area

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="padding-right:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; text-align:left
I have a multipage TIFF file that I want to divide in individual frames, save the individual frames as BMP and then show it in the PictureBox. Below code works fine but the problem is image in picturebox is showing empty area to the right of the screen.
<pre class="prettyprint private void lstInFax_SelectedIndexChanged(object sender, EventArgs e)
{
if (PictureBox1.Image != null)
PictureBox1.Image.Dispose();
System.IO.FileStream fs = null;
try
{
fs = new FileStream("C:\Adnan.TIF", FileMode.Open, FileAccess.Read);
Bitmap bm = (Bitmap)(Bitmap.FromStream(fs));

if (bm.GetFrameCount(FrameDimension.Page) > 1)
{
for (int i = 0; i < bm.GetFrameCount(FrameDimension.Page); i++)
{
bm.SelectActiveFrame(FrameDimension.Page, i);
Bitmap temp = new Bitmap(bm.Width, bm.Height);
Graphics g = Graphics.FromImage(temp);
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.DrawImageUnscaled(bm, 0, 0);
g.Dispose();
lst.Add(new Bitmap(temp));
}
}
else
lst.Add(new Bitmap(bm));
bm.Dispose();
BindingSource bs1 = new BindingSource();
bs1.DataSource = lst;
bindingNavigator1.BindingSource = bs1;

PictureBox1.Image = lst.ElementAt(Int32.Parse(bindingNavigatorPositionItem.Text) - 1);
}
finally {if(fs!=null)fs.Close();}
}[/code]
<br/>
<p style="padding-right:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; text-align:left
<img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/102779

View the full article
 
Back
Top