How can I load a Image from a file, then an image to a bitmap?
I have a file location on my file system.
I need to first load the file into开发者_运维问答 a System.Drawing.Image, then I need to load the Image into a bitmap.
try the Image.FromFile
and Bitmap.FromFile
methods. if you specifically need to convert an Image
instance into a Bitmap
instance, I think you can pass in an Image
object in the Bitmap
constructor.
Skip the "load into an Image" step, it's a one-liner:
Bitmap bmp = new Bitmap(path);
Bitmap is derived from Image, you can use it where-ever an Image object is required.
精彩评论