zoukankan      html  css  js  c++  java
  • win8平板App 文件选择和调用摄像头

    1、文件选择

     FileOpenPicker filePicker = new FileOpenPicker() { ViewMode = PickerViewMode.Thumbnail };

    //只有图片
    filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
    FillDecoderExtensions(filePicker.FileTypeFilter);

    StorageFile imageFile = await filePicker.PickSingleFileAsync();
    if (imageFile != null)
    {
    fileStream = await imageFile.OpenAsync(FileAccessMode.Read);
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.SetSource(fileStream);
    Image choosedImage = new Image();
    choosedImage.Source = bitmapImage;

    }


    //任意文件
    filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    filePicker.FileTypeFilter.Add("*");
    StorageFile choosedFile = await filePicker.PickSingleFileAsync();
    if (choosedFile != null)
    {
    const ThumbnailMode thumbnailMode = ThumbnailMode.DocumentsView;
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.SetSource(await choosedFile.GetThumbnailAsync(thumbnailMode));
    Image choosedFileThumbnail = new Image();
    choosedFileThumbnail.Source = bitmapImage;
    }

    2、调用摄像头

    Windows.Media.Capture.CameraCaptureUI dialog = new Windows.Media.Capture.CameraCaptureUI();
    StorageFile imageFile = await dialog.CaptureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.PhotoOrVideo);
    if (imageFile != null)
    {
    fileStream = await imageFile.OpenAsync(FileAccessMode.Read);
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.SetSource(fileStream);
    Image choosedImage = new Image();
    choosedImage.Source = bitmapImage;

    }

  • 相关阅读:
    JSON解析
    [Git的常见使用方式]
    [二进制]原码,反码,补码
    [伪] 级联菜单,两级菜单
    [心得]Java开发中的小心得
    [纪录]仿IOS滚轮效果(竖直滑动选择器)
    web测试总结
    科目组2
    科目组
    凭证:条目视图,总账视图
  • 原文地址:https://www.cnblogs.com/xiaofoyuan/p/2758987.html
Copyright © 2011-2022 走看看