简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM