1. display the TIFF image with the specified index page number
1. display on the page
On the display page:
Display method similar to verification code
Showtif. ASPX pageCodeWrite as follows: (this page does not contain background code)
<% @ Page Language = "C #" %>
<% @ Import namespace = "test" %>
<% Bind. showmultif ("img/AAA. tif", 1); %>
The showmultif method is defined as follows:
/**/ /// <Summary>
/// Display multi-page TIF Images
/// </Summary>
/// <Param name = "fielname"> File Name </Param>
/// <Param name = "Index"> Display page number </Param>
Public Static Void Showmultif ( String Fielname, Int Index)
{
Httpcontext Context = Httpcontext. Current;
String Bgfilepath = Context. server. mappath (fielname );
System. Drawing. Image imgobj = System. Drawing. image. fromfile (bgfilepath );
// Obtain the image on the index page
Guid objguid = (Imgobj. framedimensionslist [ 0 ]);
System. Drawing. imaging. framedimension objdimension = New System. Drawing. imaging. framedimension (objguid );
// Total number of pages
Int Totframe;
Totframe = Imgobj. getframecount (objdimension );
If (Index > Totframe)
Index = Totframe;
If (Index < 1 )
Index = 1 ;
Imgobj. selectactiveframe (objdimension, index );
// Set the output MIME type
Context. response. contenttype = " Image/GIF " ;
// Output file to the browser
//
Imgobj. Save (context. response. outputstream, system. Drawing. imaging. imageformat. GIF );
// Release resources
Context. response. Flush ();
Context. response. End ();
}
2. Use ioffice tools or image viewer to browse images by downloading and opening them
Ii. Convert TIF to JPG files
Convert TIF to multiple jpge or GIF
Public Int Savepic ( String Fullpath, Int Index)
{
// Make the specified page number within the range of this image
If (Index < 0 | Index > This . Framenumber)
{
Index=0;
}
// Draws a specified page to savegif, where savegif is the specified size.
Point ulcorner = New Point ( 0 , 0 );
Point urcorner = New Point ( This . Savewidth, 0 );
Point llcorner = New Point ( 0 , This . Saveheight );
Point [] destpara = {Ulcorner, urcorner, llcorner} ;
Savegif = New Bitmap ( This . Savewidth, This . Saveheight );
Graphics save = Graphics. fromimage (savegif );
Opentif. selectactiveframe (framedime, index );
Save. drawimage (opentif, destpara );
Save. Dispose ();
Save = Null ;
// Save Images
Savegif. Save (fullpath, imageformat. GIF );
Savegif. Dispose ();
Savegif = Null ;
Return 1 ;
}