asp.net - A generic error occurred in GDI+ when viewing a 1200 Dpi Tiff Image -


i have created tiff viewer , can view tiff images. except when @ high resolution 1200 dpi. there workaround in code causing problem?

 public function gettiffimage(path string, page integer) image           dim ms memorystream = nothing         dim srcimg image = nothing         dim returnimage image = nothing          try             srcimg = image.fromfile(path)             ms = new memorystream()             dim frdim new framedimension(srcimg.framedimensionslist(0))             srcimg.selectactiveframe(frdim, page)             srcimg.save(ms, imageformat.tiff)             returnimage = image.fromstream(ms)         catch ex exception             throw ex                     srcimg.dispose()             gc.collect()             gc.waitforpendingfinalizers()         end try          return returnimage     end function 

thanks in advance

in experience error message misleading , it's caused outofmemoryexception. i'd wager you're losing memory because you're failing clean of idisposable objects. understand gc.collect() isn't reliable approach. try putting using blocks in. use c# not vbscript can't give exact syntax in c# it'd this:

using (var srcimg = image.fromfile(path)) {   using (var ms = memorystream())   {     var frdim = new framedimension(srcimg.framedimensionslist(0));     srcimg.selectactiveframe(frdim, page)     srcimg.save(ms, imageformat.tiff)     using (var returnimage = image.fromstream(ms))     {       return returnimage;     }   } } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -