Michael
Michael

Reputation: 13636

How to get the file name Bitmap object?

Here is my C# code:

    public static void FilterNoises(Bitmap bmp)
    {
        Image<Bgr, Byte> img = new Image<Bgr, byte>(bmp);
        img.PyrUp().PyrDown();
        img.Save(@"C:\Users\Desktop\Road Images\Filtered Images\" +   "filename.extension");
    }

I need to get the file name and extansion from bmp object. Any idea how to do it?

Upvotes: 0

Views: 1549

Answers (1)

Craig Godden-Payne
Craig Godden-Payne

Reputation: 245

You should have the file name and extension from when you loaded the bitmap, you can get the filename directly from the Bitmap object itself

var filename = @"C:\Filename.bmp";
var bitmap = new Bitmap(System.Drawing.Image.FromFile(fileName, true));

Upvotes: 1

Related Questions