如何从Image知道ImageFormat? [英] How to know ImageFormat from Image?

查看:105
本文介绍了如何从Image知道ImageFormat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发掌上电脑.
我有一个公共属性,属性为[EditorBrowsable()].
当我尝试将* .ico格式加载到Image并调用某些功能时,我在GDI +中收到错误消息.如何在设计时从OpenFileDialog中排除* .ico格式或从Image中获取ImageFormat?
对不起,我的英语.
thx.

I develop pocket pc.
I have a public property with attribute .
When I try to load *.ico format into Image and summon some function I get an error in GDI+. How to exclude *.ico format from OpenFileDialog in Design-time or get ImageFormat from Image?
Sorry for my English.
thx.

推荐答案

文件对话框具有
File Dialogs have a Filter[^] property that allows you to exclude any file types that you don''t want. If you set it to only show files of image types (bmp, jpg, and png for example) then you can be fairly sure that the file path it returns won''t cause problems when you load it using the Image class.

When loading a file using Image.FromFile or something equivalent it''s always good to put a try - catch around the call just in case the image is valid. That should catch the case of trying to load an Icon (or something else) into an Image.


我知道.但是,如何在设计时间上的OpenFileDialog上设置过滤器?
I know that. But how to set filter on OpenFileDialog in Design time?


这篇关于如何从Image知道ImageFormat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆