protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { backsoundButton.Source = new Uri("Audio/BacksoundGameplay.mp3", UriKind.RelativeOrAbsolute); backsoundButton.Play(); //string msg; //if (NavigationContext.QueryString.TryGetValue("gambar", out msg)) //{ // MessageBox.Show(msg); // bitmapGet = new System.Windows.Media.Imaging.BitmapImage(new Uri(msg, UriKind.Absolute)); // imageBatik.Source = bitmapGet; // bmpBatik = (BitmapImage)imageBatik.Source; //} try { BitmapImage bitmapGet = Navigation.Bmp; //PhoneApplicationService.Current.State["imageBatik"] as BitmapImage; System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(bitmapGet); wbEdited = new System.Windows.Media.Imaging.WriteableBitmap(width, height); wbHasilSobel = new System.Windows.Media.Imaging.WriteableBitmap(width, height); int[] rgb = wb.Pixels; int grayScale, a, r, g, b; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { a = rgb[(y * width) + x] >> 24; r = (rgb[(y * width) + x] & 0x00ff0000) >> 16; g = (rgb[(y * width) + x] & 0x0000ff00) >> 8; b = (rgb[(y * width) + x] & 0x000000ff); grayScale = (r + g + b) / 3; SetPikselCitra(x, y, (byte)a, grayScale, grayScale, grayScale); } } Kelas.Sobel sobelOperator = new Kelas.Sobel(); wbHasilSobel = sobelOperator.CitraSobel(wbEdited); imagePolaBatik.Source = wbHasilSobel; this.imageBatik.Source = bitmapGet; LoadURL(); } catch (Exception ez) { MessageBox.Show("Nyorek"+ez.Message); } base.OnNavigatedTo(e); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { //string msg; backsoundButton.Source = new Uri("Audio/BacksoundGameplay2.mp3", UriKind.RelativeOrAbsolute); backsoundButton.Play(); try { BitmapImage bitmapGet = Navigation.Bmp; //PhoneApplicationService.Current.State["imageBatik"] as BitmapImage; System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(bitmapGet); wbEdited = new System.Windows.Media.Imaging.WriteableBitmap(width, height); wbHasilSobel = new System.Windows.Media.Imaging.WriteableBitmap(width, height); int[] rgb = wb.Pixels; int grayScale, a, r, g, b; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { a = rgb[(y * width) + x] >> 24; r = (rgb[(y * width) + x] & 0x00ff0000) >> 16; g = (rgb[(y * width) + x] & 0x0000ff00) >> 8; b = (rgb[(y * width) + x] & 0x000000ff); grayScale = (r + g + b) / 3; SetPikselCitra(x, y, (byte) a, grayScale, grayScale, grayScale); } } Kelas.Sobel sobelOperator = new Kelas.Sobel(); wbHasilSobel = sobelOperator.CitraSobel(wbEdited); imagePolaBatik.Source = wbHasilSobel; this.imageBatik.Source = bitmapGet; LoadURL(); } catch (Exception ez) { MessageBox.Show("Nyorek" + ez.Message); } foreach (Line oldLine in Helper.hasilNgelowong) { Line line = new Line(); line.X1 = oldLine.X1; line.Y1 = oldLine.Y1; line.X2 = oldLine.X2; line.Y2 = oldLine.Y2; line.Stroke = oldLine.Stroke; line.Fill = oldLine.Fill; line.StrokeThickness = oldLine.StrokeThickness; canvasGambarBatik.Children.Add(line); } base.OnNavigatedTo(e); }