Bitmap.FromFile(路径)和新的位图(路径)之间的区别 [英] Difference between Bitmap.FromFile(path) and new Bitmap(path)
问题描述
位图bitmap1 =新的位图(C:\\\ \\test.bmp);
位图bitmap2 =(位图)Bitmap.FromFile(C:\\test.bmp);
一种方法比另一种更好吗?是否 在你的情况下,你要做的是调用FromFile方法并获取一个Image对象,然后将其转换为Bitmap。当你有Bitmap构造函数来做到这一点时为什么要这样做。 I woud like to know the difference between these two: Is one option better than the other one? Does 'FromFile' method is available through base class 'Image'(which is an abstract class) to 'Bitmap' class and it returns an Image object. Where as 'Bitmap' is the child class which inherits 'Image' class and Bitmap constructor allows you to initialize Bitmap object directly. In your case what you are trying to do is, call FromFile method and get an Image object then type cast it to Bitmap. Why to do this when you have Bitmap constructor to do this.
Does Bitmap.FromFile(path) fills in any additional data to the bitmap image:
No 这篇关于Bitmap.FromFile(路径)和新的位图(路径)之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! Bitmap.FromFile(path)
会将任何附加数据填充到位图图像中,还是仅仅代表新位图(路径)$我们可以通过基类'Image'(这是一个抽象类)来获取'FromFile'方法, 'Bitmap'类,它返回一个Image对象。 'Bitmap'是继承'Image'类的子类,Bitmap构造函数允许你直接初始化Bitmap对象。
Bitmap.FromFile(路径)是否将任何附加数据填充到位图图像:
否Bitmap bitmap1 = new Bitmap("C:\\test.bmp");
Bitmap bitmap2 = (Bitmap) Bitmap.FromFile("C:\\test.bmp");
Bitmap.FromFile(path)
fills in any additional data to the bitmap image or is it just a delegate to new Bitmap(path)
?