public async Task <bool> LoadImage() { bool bRst = true; try { var openFile = await m_storageFile.OpenReadAsync(); m_bitmap = new BitmapImage(); m_bitmap.SetSource(openFile); pictureBoxOriginal.Source = m_bitmap; m_softwareBitmap = await ComFunc.CreateSoftwareBitmap(m_storageFile, m_bitmap); m_strCurImgName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); SelectLoadImage(m_strCurImgName); } catch (Exception) { bRst = false; return(bRst); } return(bRst); }
public async void OnClickBtnStart(object sender, RoutedEventArgs e) { pictureBoxAfter.Source = null; btnFileSelect.IsEnabled = false; btnAllClear.IsEnabled = false; btnStart.IsEnabled = false; bool bLoadImageResult = await LoadImage(); if (bLoadImageResult) { bool bTaskResult = await TaskWorkImageProcessing(); if (bTaskResult) { m_strCurImgName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); pictureBoxAfter.Source = await ComFunc.ConvertToSoftwareBitmapSource(SelectGetBitmap(m_strCurImgName)); } } btnFileSelect.IsEnabled = true; btnAllClear.IsEnabled = true; btnStart.IsEnabled = true; return; }
/// <summary> /// 設定の読込 /// </summary> public void LoadParam() { var settings = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(ComInfo.RESOURCE_IMG_PROC_TYPE); if (settings != null) { List <ComImageProcessingType> items = new List <ComImageProcessingType>(); items.Add(new ComImageProcessingType(int.Parse(settings.GetString(ComInfo.IMG_TYPE_EDGE_ID)), settings.GetString(ComInfo.IMG_TYPE_EDGE_NAME))); items.Add(new ComImageProcessingType(int.Parse(settings.GetString(ComInfo.IMG_TYPE_GRAY_SCALE_ID)), settings.GetString(ComInfo.IMG_TYPE_GRAY_SCALE_NAME))); items.Add(new ComImageProcessingType(int.Parse(settings.GetString(ComInfo.IMG_TYPE_BINARIZATION_ID)), settings.GetString(ComInfo.IMG_TYPE_BINARIZATION_NAME))); items.Add(new ComImageProcessingType(int.Parse(settings.GetString(ComInfo.IMG_TYPE_GRAY_SCALE_2DIFF_ID)), settings.GetString(ComInfo.IMG_TYPE_GRAY_SCALE_2DIFF_NAME))); items.Add(new ComImageProcessingType(int.Parse(settings.GetString(ComInfo.IMG_TYPE_COLOR_REVERSAL_ID)), settings.GetString(ComInfo.IMG_TYPE_COLOR_REVERSAL_NAME))); cmbBoxImageProcessingType.Items.Add(settings.GetString(ComInfo.IMG_TYPE_EDGE_NAME)); cmbBoxImageProcessingType.Items.Add(settings.GetString(ComInfo.IMG_TYPE_GRAY_SCALE_NAME)); cmbBoxImageProcessingType.Items.Add(settings.GetString(ComInfo.IMG_TYPE_BINARIZATION_NAME)); cmbBoxImageProcessingType.Items.Add(settings.GetString(ComInfo.IMG_TYPE_GRAY_SCALE_2DIFF_NAME)); cmbBoxImageProcessingType.Items.Add(settings.GetString(ComInfo.IMG_TYPE_COLOR_REVERSAL_NAME)); string strImgTypeSelectName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); if (!string.IsNullOrWhiteSpace(strImgTypeSelectName)) { cmbBoxImageProcessingType.SelectedIndex = (int)items.Find(x => x.Name == strImgTypeSelectName)?.Id - 1; } if (cmbBoxImageProcessingType.SelectedIndex == -1) { cmbBoxImageProcessingType.SelectedIndex = 0; } } return; }
public MainPage() { InitializeComponent(); InitMemberVariables(); m_strCurImgName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); sliderThresh.IsEnabled = m_strCurImgName == ComInfo.IMG_NAME_BINARIZATION ? true : false; }
private void OnSliderKeyUp(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { m_strCurImgName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); if (m_strCurImgName != ComInfo.IMG_NAME_BINARIZATION) { return; } if (pictureBoxAfter.Source != null) { OnClickBtnStart(sender, e); } }
public async Task <bool> TaskWorkImageProcessing() { m_tokenSource = new CancellationTokenSource(); CancellationToken token = m_tokenSource.Token; ComImgInfo imgInfo = new ComImgInfo(); BinarizationInfo binarizationInfo = new BinarizationInfo(); binarizationInfo.Thresh = (byte)sliderThresh.Value; imgInfo.CurImgName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); imgInfo.BinarizationInfo = binarizationInfo; bool bRst = await Task.Run(() => SelectGoImgProc(imgInfo, token)); return(bRst); }
protected override void OnNavigatedTo(NavigationEventArgs e) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = Frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested += GoBack; string strCurImgName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); if (m_strCurImgName != strCurImgName) { SelectLoadImage(strCurImgName); pictureBoxAfter.Source = null; } sliderThresh.IsEnabled = strCurImgName == ComInfo.IMG_NAME_BINARIZATION ? true : false; base.OnNavigatedTo(e); }
public async void OnClickBtnShowHistgram(object sender, RoutedEventArgs e) { if (m_bitmap == null) { return; } var histgramData = new ComHistgramData(); if (m_bitmap != null) { histgramData.SoftwareBitmapOriginal = await ComFunc.CreateSoftwareBitmap(m_storageFile, m_bitmap); } string strCurImgName = ComFunc.GetStringApplicationDataContainer(ComInfo.IMG_TYPE_SELECT_NAME); if (SelectGetStatus(strCurImgName) == (int)ComInfo.ImageProcStatus.Implemented) { histgramData.SoftwareBitmapAfter = SelectGetBitmap(strCurImgName); } if (m_bitmap != null) { Frame.Navigate(typeof(HistgramLiveChartsPage), histgramData); } }