public Watermark CopyOf() { if (ImageSource == null) { return(null); } var waterMark = new Watermark { ImageSource = _imageSource.Clone(), Opacity = _opacity, Size = _size }; return(waterMark); }
private static Watermark CheckGreyMark(Watermark mark, bool blackAndWhite) { if (mark == null || mark.ImageSource == null) { return(null); } if (!blackAndWhite) { return(mark); } var newMark = new Watermark { Opacity = mark.Opacity, Size = mark.Size }; byte[] markBytes; using (var stream = new MemoryStream()) { var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create((BitmapSource)mark.ImageSource)); encoder.Save(stream); markBytes = stream.ToArray(); } using (var stream = new MemoryStream(markBytes)) { var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = stream; bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.EndInit(); bitmap.Freeze(); var grayBitmapSource = new FormatConvertedBitmap(); grayBitmapSource.BeginInit(); grayBitmapSource.Source = bitmap; grayBitmapSource.DestinationFormat = PixelFormats.Gray32Float; grayBitmapSource.EndInit(); newMark.ImageSource = grayBitmapSource; } return(newMark); }
public TextFile() { //ScrollOffset = -1d; IncFontWhenPrinting = 0; Watermark = new Watermark { Size = new Size(1, 1), Opacity = 1d }; PageCountElement = new PageCountElement { FontFamily = MainWindow.Global.FindResource("defaultFont") as FontFamily, ForgroundBrush = Brushes.Black, UseLeadingZero = false }; SpellCheckEnabled = true; Styles = new ComplexStyles(); OpeningQuote = ClosingQuote = "\u0022"; SingleOpeningQuote = SingleClosingQuote = "\u0027"; ReadOnly = false; Characters = new ObservableCollection <Character>(); Characters.CollectionChanged += CharactersCollectionChanged; }
private void LoadWatermark(SerializationInfo info) { try { Watermark = new Watermark(); var arr = (byte[])info.GetValue("Watermark", typeof(byte[])); if (arr == null) { return; } Watermark.ImageSource = Utilities.GetImageSourceFromByteArray(arr); Watermark.Size = (Size)info.GetValue("WatermarkSize", typeof(Size)); Watermark.Opacity = info.GetDouble("WatermarkOpacity"); } catch (Exception) { Watermark = new Watermark { Size = new Size(1, 1), Opacity = 1d }; } }