Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,,



VB
Dim fs As New FileStream(Filename, FileMode.Open, FileAccess.Read, FileShare.Read)
       'Dim fs As FileStream = File.Open(Filename, FileMode.Open, FileAccess.Read)
       Dim bm As System.Drawing.Bitmap = CType(System.Drawing.Bitmap.FromStream(fs), System.Drawing.Bitmap)
       bm.SelectActiveFrame(FrameDimension.Page, FrameNumber)
       Dim temp As New System.Drawing.Bitmap(bm.Width, bm.Height)
       Dim g As Graphics = Graphics.FromImage(temp)
       g.InterpolationMode = InterpolationMode.NearestNeighbor
       g.DrawImage(bm, 0, 0, bm.Width, bm.Height)



//Dim fs As New FileStream(Filename, FileMode.Open, FileAccess.Read, FileShare.Read)

this line of code raising generic error occured GDI+ only 1 or 2 cases out of 100..
am trying read frame from tiff..more ceases its working ..please help me if u have any idea

[edit]Title: "GUI+" changed to "GDI+", tags changed from C# to VB - OriginalGriff[/edit]
Posted
Updated 11-Oct-13 1:53am
v2
Comments
Ian A Davidson 11-Oct-13 7:07am    
This is not C#

Why not just use
VB
Dim dm As Bitmap = DirectCast(Image.FromFile(Filename), Bitmap)
bm.SelectActiveFrame(FrameDimension.Page, FrameNumber)


If you are getting the error on the same file each time, then it is likely that the file contains bad information, or info that .NET does not understand. I would use a Try...Catch statement, log my problems and review the files outside the code to see if they have a common factor as the first stage.
 
Share this answer
 
Comments
santhosht 15-Oct-13 3:17am    
error raising at this line bm.SelectActiveFrame(FrameDimension.Page, FrameNumber)
santhosht 15-Oct-13 3:20am    
Hai sir getting error on same page not in same file..the file contains good information
once try like this
Dim fs As New FileStream(Filename, FileMode.Open, FileAccess.Read)
 
Share this answer
 
Comments
santhosht 15-Oct-13 3:12am    
@Mani Yes i tried thay way to ..dats also not working i put comment to that code
santhosht 15-Oct-13 3:17am    
error raising at the line bm.SelectActiveFrame(FrameDimension.Page, FrameNumber)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900