user4470962
user4470962

Reputation:

how to Customize windows 8.1 camera app for C# wpf application

I am creating WPF application, for my webcam section am using built-in metro camera app. Since this application is an Desktop application, i just want to use Metro Camera app for the sake of capturing Image and editing. After capturing the images its getting saved in This PC-->Pictures folder, but i want to save the images in some other folder and also i want to give a name for the images manually. Is there any way to do this?

Upvotes: 1

Views: 376

Answers (1)

Ali Vojdanian
Ali Vojdanian

Reputation: 2111

Here is the code for saving images :

    void SaveToBmp(FrameworkElement visual, string fileName)
{
    var encoder = new BmpBitmapEncoder();
    SaveUsingEncoder(visual, fileName, encoder);
}

void SaveToPng(FrameworkElement visual, string fileName)
{
    var encoder = new PngBitmapEncoder();
    SaveUsingEncoder(visual, fileName, encoder);
}

// and so on for other encoders (if you want)


void SaveUsingEncoder(FrameworkElement visual, string fileName, BitmapEncoder encoder)
{
    RenderTargetBitmap bitmap = new RenderTargetBitmap((int)visual.ActualWidth, (int)visual.ActualHeight, 96, 96, PixelFormats.Pbgra32);
    bitmap.Render(visual);
    BitmapFrame frame = BitmapFrame.Create(bitmap);
    encoder.Frames.Add(frame);

    using (var stream = File.Create(fileName))
    {
        encoder.Save(stream);
    }
}

Here is the source for that.

Update :

If you want to save images in metro app you can use Pictures Library for that.

Read these following questions for that :

Download and Save image in Pictures Library through Windows 8 Metro XAML App

How save photo capture windows 8 c# metro app?

Hope it helps.

Upvotes: 1

Related Questions