Converting System.Web.UI.WebControls.Image to System.Drawing.Image?

百般思念 提交于 2019-12-02 12:44:01

问题


I can't seem to convert it. Any help?


回答1:


They are two completely different objects:

  • System.Web.UI.WebControls.Image is a control that has the ability to render HTML which will make the browser download and display an appointed image
  • System.Drawing.Image is a class that has the ability to load an image into memory for manipulating it, or to display it in a control (but not the web image control).

So unfortunately there is no way you can convert a System.Web.UI.WebControls.Image to a System.Drawing.Image; it doesn't even touch the image data.




回答2:


System.Web.UI.WebControls.Image is merely a container for any valid image file specified by the ImageUrl property. If you would like to take the image at the ImageUrl and convert it to a System.Drawing.Image you can call System.Drawing.Image.ImageFromFile("path/to/image").



来源:https://stackoverflow.com/questions/1357826/converting-system-web-ui-webcontrols-image-to-system-drawing-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!