C# picturebox brings up Red X -


i trying zoom image. here code. @ times red x box comes up. unable resolve this. great if me this.

 private void radbtnzoomin_click(object sender, eventargs e)         {             try             {                 m_presentangle = 0;                 gc.collect();                 image originalimg = system.drawing.image.fromfile(m_filepath);                 originalimg.selectactiveframe(system.drawing.imaging.framedimension.page, m_intcurrpage);                 if (originalimg != null  && m_zoominpresentpercent < 500)                 {                     int zoompercentrequired = 0;                     if(m_zoominpresentpercent >=100)                     {                         zoompercentrequired = m_zoominpresentpercent + 100;                     }                     else                     {                         zoompercentrequired = m_zoominpresentpercent + 20;                     }                                         cbzoompercentage.text = zoompercentrequired + "%";                     double zoom = zoompercentrequired / 100.0;                     bitmap bmp = new bitmap(originalimg, convert.toint32(originalimg.width * zoom), convert.toint32(originalimg.height * zoom));                     graphics g = graphics.fromimage(bmp);                     g.interpolationmode = interpolationmode.highqualitybicubic;                     picturebox1.image = bmp;                     img = picturebox1.image;                      m_zoominpresentpercent = zoompercentrequired;                 }                 if (!(m_zoomincount > 5))                 {                     m_zoomincount++;                 }                 if(m_zoomoutcount >0)                 {                      m_zoomoutcount--;                 }                 gc.collect();             }             catch(exception ex)             {                 try                 {                     gc.collect();                     messagebox.show("the image small or big zoomed. loading original image");                      disposeimage();                     refreshimage(m_filepath, m_width, m_height);                     gc.collect();                 }                 catch(exception exp)                 {                     throw new exception("from zoom, " + exp.message + " application needs exit");                 }             }         } 


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -