public IRenderImageSource CreateRenderImageSource(string uri, Rect sourceRect) { if (!IsUrl(uri)) { return CreateRenderImageSource(RenderImageType.Unknown, EmbeddedResourceLoader.LoadResourceData(uri), sourceRect); } wpf::System.Windows.Media.Imaging.BitmapImage bitmapImage = new wpf::System.Windows.Media.Imaging.BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri(uri); if (!sourceRect.IsNullOrEmpty()) { bitmapImage.SourceRect = new wpf::System.Windows.Int32Rect((int)sourceRect.Left, (int)sourceRect.Top, (int)sourceRect.Width, (int)sourceRect.Height); } bitmapImage.EndInit(); return new WpfRenderImageSource(bitmapImage); }
public IRenderImageSource CreateRenderImageSource(RenderImageType imageType, byte[] data, Rect sourceRect) { wpf::System.Windows.Media.Imaging.BitmapImage bitmapImage = new wpf::System.Windows.Media.Imaging.BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = new MemoryStream(data); if (!sourceRect.IsNullOrEmpty()) { bitmapImage.SourceRect = new wpf::System.Windows.Int32Rect((int)sourceRect.Left, (int)sourceRect.Top, (int)sourceRect.Width, (int)sourceRect.Height); } bitmapImage.EndInit(); return new WpfRenderImageSource(bitmapImage); }
public static bool Contains(this Rect @this, Rect rect) { return(rect.IsNullOrEmpty() || [email protected]() && @this.Left <= rect.Left && @this.Top <= rect.Top && @this.Right >= rect.Right && @this.Bottom >= rect.Bottom); }
public static Rect DefaultIfNullOrEmpty(this Rect rect, Rect defaultValue = null) { return(rect.IsNullOrEmpty() ? (defaultValue ?? Rect.Zero) : rect); }
public static bool Contains(this Rect rect, Point point) { return(point.IsNullOrEmpty() || !rect.IsNullOrEmpty() && rect.Left <= point.X && point.X < rect.Right && rect.Top <= point.Y && point.Y < rect.Bottom); }