获取位图文件名 [英] Get bitmap file name

查看:148
本文介绍了获取位图文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面创建位图我这行:

I use this line below for create my Bitmap:

Bitmap b = new Bitmap(@"C:\<file name>");

在我修改此位图,我想将它保存在下面一行:

After I modify this bitmap and I want to save it as in line below:

b.Save(@"C:\\<other file name>")

我的问题是 - 如何从属性文件名的位图

简单地说,我需要保存位图与我所发起它的名称相同。

My question is - how to get the file name bitmap from property.
Simply put, I need to save the bitmap with the same name with whom I had initiated it.

感谢

推荐答案

也许你可以用做到这一点元数据 - 但我不熟悉这个主题,所以我不能完全肯定这是可能的,我也不怎么办呢

我的做什么的建议是做一个类型。

Perhaps you can do this with Metadata - but I'm not familiar with this subject so I'm not completely sure it's possible, nor do I how to do it.
What I do suggest is make a type.

因此​​,例如,你可以创建一个类里面会有一个位图 (1)属性的图像,为文件的路径的字符串。

So for example you can create a class which will have a Bitmap(1) property for the image, and a string for the file's path.

class LocalBitmap
{
    public Bitmap Bitmap { get; set; }
    public String Path { get; set; }

    public LocalBitmap(String path)
    {
        Path = path;
        Bitmap = new Bitmap(path);
    }
}

和使用它像这样:

LocalBitmapimage = new LocalBitmap(@"C:\myImage.bmp");



(1)考虑使用图片类代替。这是基类位图的。如果你不能确定使用哪一个问自己,如果你的类需要一个图像或确切格式的图像(即位图)。


(1) Consider using the Image class instead. It's the base class of Bitmap. If you're not sure which one to use ask yourself if your class requires an image or an image of that exact format (that is, bitmap).

这篇关于获取位图文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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