private void saveImage() { PersonName.FontSize = 50; WriteableBitmap wbBitmap = new WriteableBitmap(InkPresenter, new TranslateTransform()); EditableImage eiImage = new EditableImage(wbBitmap.PixelWidth, wbBitmap.PixelHeight); try { for (int y = 0; y < wbBitmap.PixelHeight; ++y) { for (int x = 0; x < wbBitmap.PixelWidth; ++x) { int pixel = wbBitmap.Pixels[wbBitmap.PixelWidth * y + x]; eiImage.SetPixel(x, y, (byte)((pixel >> 16) & 0xFF), (byte)((pixel >> 8) & 0xFF), (byte)(pixel & 0xFF), (byte)((pixel >> 24) & 0xFF) ); } } } catch (System.Security.SecurityException) { throw new Exception("Cannot print images from other domains"); } // Save it to disk Stream streamPNG = eiImage.GetStream(); Debug.WriteLine("Speichere als " + Person1 + FormID + "Signum.png"); if (App.formHandler.SaveSignum(streamPNG, (Person1 + FormID))) { Debug.WriteLine("Foto erfolgreich als " + Person1 + FormID + "Signum.png gespeichert"); GlobalSettings.HasSignedList.Add(Person1 + FormID); } else { Debug.WriteLine("Fehler beim Speichern."); } }
private void MakeABackground(String Name, bool signable) { InkPresenter presenter = new InkPresenter(); presenter.Width = 655; presenter.Height = 480; presenter.Background = new SolidColorBrush(Colors.Black); Line line = new Line(); line.X1 = 20; line.X2 = 635; line.Y1 = 380; line.Y2 = 380; if (signable) { line.Stroke = new SolidColorBrush(Colors.White); } else { line.Stroke = new SolidColorBrush(Colors.DarkGray); } line.StrokeThickness = 2; presenter.Children.Add(line); TextBlock text = new TextBlock(); text.Text = Name; if (signable) { text.Foreground = new SolidColorBrush(Colors.White); } else { text.Foreground = new SolidColorBrush(Colors.DarkGray); } text.FontSize = 50; text.Margin = new Thickness(20, 400, 0, 0); presenter.Children.Add(text); WriteableBitmap wbBitmap = new WriteableBitmap(presenter, new TranslateTransform()); EditableImage eiImage = new EditableImage(wbBitmap.PixelWidth, wbBitmap.PixelHeight); try { for (int y = 0; y < wbBitmap.PixelHeight; ++y) { for (int x = 0; x < wbBitmap.PixelWidth; ++x) { int pixel = wbBitmap.Pixels[wbBitmap.PixelWidth * y + x]; eiImage.SetPixel(x, y, (byte)((pixel >> 16) & 0xFF), (byte)((pixel >> 8) & 0xFF), (byte)(pixel & 0xFF), (byte)((pixel >> 24) & 0xFF) ); } } } catch (System.Security.SecurityException) { throw new Exception("Cannot print images from other domains"); } Stream streamPNG = eiImage.GetStream(); App.formHandler.SaveSignum(streamPNG, Name + "Button"); }