protected override void DrawVisualThumbnail(DrawingContext drawingContext, out string title, ref BitmapSource icon) { var aeroColor = (Color) Application.Current.Resources["AeroColor"]; var aeroBrush = new SolidColorBrush(aeroColor); var aeroPen = new Pen(aeroBrush, 7); var largeIcon = (BitmapSource) Application.Current.Resources["TextClipboardItemIcon"]; var fontFamily = (FontFamily) Application.Current.Resources["CuprumFont"]; var typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Light, FontStretches.Normal); const int textOffset = VisualThumbnailMargin + 51 + VisualThumbnailMargin / 2; var text = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 15, aeroBrush); text.TextAlignment = TextAlignment.Left; text.MaxTextWidth = VisualThumbnailWidth - textOffset - VisualThumbnailMargin; text.MaxTextHeight = VisualThumbnailHeight - VisualThumbnailMargin * 2; drawingContext.DrawRectangle(Brushes.White, aeroPen, new Rect(-1, -1, VisualThumbnailWidth + 2, VisualThumbnailHeight + 2)); drawingContext.DrawImage(largeIcon, new Rect(VisualThumbnailMargin, VisualThumbnailMargin, 51, 66)); drawingContext.DrawText(text, new Point(textOffset, VisualThumbnailMargin)); title = Text; }
private void CalculateLuminanceRGB(BitmapSource bitmap) { var width = bitmap.PixelWidth; var height = bitmap.PixelHeight; var stepX = (bitmap.Format.BitsPerPixel + 7) / 8; var bufferSize = width * stepX; var buffer = new byte[bufferSize]; var rect = new Int32Rect(0, 0, width, 1); var luminanceIndex = 0; luminances = new byte[width * height]; for (var curY = 0; curY < height; curY++) { bitmap.CopyPixels(rect, buffer, bufferSize, 0); for (var curX = 0; curX < bufferSize; curX += stepX) { var r = buffer[curX]; var g = buffer[curX + 1]; var b = buffer[curX + 2]; luminances[luminanceIndex] = (byte) (0.3 * r + 0.59 * g + 0.11 * b + 0.01); luminanceIndex++; } rect.Y++; } }
protected override void DrawVisualThumbnail(System.Windows.Media.DrawingContext drawingContext, out string title, ref BitmapSource icon) { var aeroColor = (Color)Application.Current.Resources["AeroColor"]; var aeroBrush = new SolidColorBrush(aeroColor); var aeroPen = new Pen(aeroBrush, 7); var grayBrush = new SolidColorBrush(Color.FromArgb(255, 0xaf, 0xaf, 0xaf)); var fontFamily = (FontFamily)Application.Current.Resources["CuprumFont"]; var typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Light, FontStretches.Normal); const int sourceTextOffset = VisualThumbnailMargin; var sourceText = new FormattedText(Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 14, grayBrush); sourceText.MaxTextWidth = VisualThumbnailWidth - sourceTextOffset - VisualThumbnailMargin; sourceText.MaxTextHeight = 32; var imageRectangle = new Rect(VisualThumbnailWidth / 2 - 64 / 2, VisualThumbnailHeight / 2 - 64 / 2, 64, 64); drawingContext.DrawRectangle(Brushes.White, aeroPen, new Rect(-1, -1, VisualThumbnailWidth + 2, VisualThumbnailHeight + 2)); drawingContext.DrawImage(Icon, imageRectangle); drawingContext.DrawText(sourceText, new Point(sourceTextOffset, VisualThumbnailHeight - VisualThumbnailMargin - 16)); title = Name + " from " + Source.ApplicationName; }
/// <summary> /// Initializes a new instance of the <see cref="BitmapSourceLuminanceSource"/> class. /// </summary> /// <param name="bitmap">The bitmap.</param> public BitmapSourceLuminanceSource(BitmapSource bitmap) : base(bitmap.PixelWidth, bitmap.PixelHeight) { switch (bitmap.Format.ToString()) { case "Bgr24": case "Bgr32": CalculateLuminanceBGR(bitmap); break; case "Bgra32": CalculateLuminanceBGRA(bitmap); break; case "Rgb24": CalculateLuminanceRGB(bitmap); break; case "Bgr565": CalculateLuminanceBGR565(bitmap); break; default: // there is no special conversion routine to luminance values // we have to convert the image to a supported format bitmap = new FormatConvertedBitmap(bitmap, PixelFormats.Bgra32, null, 0); CalculateLuminanceBGR(bitmap); break; } }
protected override void DrawVisualThumbnail(System.Windows.Media.DrawingContext drawingContext, out string title, ref BitmapSource icon) { var aeroColor = (Color)Application.Current.Resources["AeroColor"]; var aeroBrush = new SolidColorBrush(aeroColor); var aeroPen = new Pen(aeroBrush, 7); var grayBrush = new SolidColorBrush(Color.FromArgb(0x70, 255, 255, 255)); var transparencyOverlayBrush = new SolidColorBrush(Color.FromArgb(0x22, 0, 0, 0)); var fontFamily = (FontFamily)Application.Current.Resources["CuprumFont"]; var typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Light, FontStretches.Normal); const int sourceTextOffset = VisualThumbnailMargin + 16 + VisualThumbnailMargin / 2; var sourceText = new FormattedText(Source.ApplicationName ?? "Unknown application", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 14, grayBrush); sourceText.MaxTextWidth = VisualThumbnailWidth - sourceTextOffset - VisualThumbnailMargin; sourceText.MaxTextHeight = 32; var imageRectangle = new Rect(-1, -1, VisualThumbnailWidth + 1 * 2, VisualThumbnailHeight + 1 * 2); drawingContext.DrawImage(Image, imageRectangle); drawingContext.DrawRectangle(transparencyOverlayBrush, aeroPen, imageRectangle); drawingContext.DrawImage(Source.Icon, new Rect(VisualThumbnailMargin, VisualThumbnailHeight - VisualThumbnailMargin - 16, 16, 16)); drawingContext.DrawText(sourceText, new Point(sourceTextOffset, VisualThumbnailHeight - VisualThumbnailMargin - 16)); title = "Image from " + Source.ApplicationName; }
private void ImageUpdated(BitmapSource bitmap) { var bitmapImage = bitmap as BitmapImage; if (bitmapImage != null) { bitmapImage.ImageOpened += BitmapImageOpened; bitmapImage.ImageFailed += BitmapImageFailed; } else { SwapImages(); } }
private void AddDownloadEventHandlers(BitmapSource bitmap) { var bitmapImage = bitmap as BitmapImage; if (bitmapImage != null) { bitmapImage.ImageOpened += BitmapImageOpened; bitmapImage.ImageFailed += BitmapImageFailed; } else { BlendImages(); } }
/// <summary> /// Converts the input BitmapSource to the Pbgra32 format WriteableBitmap which is internally used by the WriteableBitmapEx. /// </summary> /// <param name="source">The source bitmap.</param> /// <returns></returns> public static WriteableBitmap ConvertToPbgra32Format(BitmapSource source) { // Convert to Pbgra32 if it's a different format if (source.Format == PixelFormats.Pbgra32) { return new WriteableBitmap(source); } var formatedBitmapSource = new FormatConvertedBitmap(); formatedBitmapSource.BeginInit(); formatedBitmapSource.Source = source; formatedBitmapSource.DestinationFormat = PixelFormats.Pbgra32; formatedBitmapSource.EndInit(); return new WriteableBitmap(formatedBitmapSource); }
/// <summary> /// Executes this drop shadow /// filter on the input image and returns the result /// </summary> /// <param name="inputImage">input image</param> /// <returns>Shadow Dropped Image</returns> /// <example> /// <code> /// Image transformed; /// DropShadowFilter dropShadow = new DropShadowFilter(); /// transformed = dropShadow.ExecuteFilter(myImg); /// </code> /// </example> public override BitmapSource ExecuteFilter(BitmapSource inputImage) { int rightMargin = 4; int bottomMargin = 4; //Get the shadow image Assembly asm = Assembly.GetExecutingAssembly(); ResourceManager rm = new ResourceManager("Genetibase.UI.NuGenImageWorks.ExtraFilters.Images", asm); Bitmap shadow = (Bitmap)rm.GetObject("img"); Bitmap fullImage = new Bitmap(inputImage.Width + 6, inputImage.Height + 6); Graphics g = Graphics.FromImage(fullImage); g.DrawImage(inputImage, 0, 0, inputImage.Width, inputImage.Height); GraphicsUnit units = GraphicsUnit.Pixel; //Draw the shadow's right lower corner Point ulCorner = new Point(fullImage.Width - 6, fullImage.Height - 6); Point urCorner = new Point(fullImage.Width, fullImage.Height - 6); Point llCorner = new Point(fullImage.Width - 6, fullImage.Height); Point[] destPara = { ulCorner, urCorner, llCorner }; Rectangle srcRect = new Rectangle(shadow.Width - 6, shadow.Height - 6, 6, 6); g.DrawImage(shadow, destPara, srcRect, units); //Draw the shadow's right hand side ulCorner = new Point(fullImage.Width - 6, bottomMargin); urCorner = new Point(fullImage.Width, bottomMargin); llCorner = new Point(fullImage.Width - 6, fullImage.Height - 6); destPara = new Point[] { ulCorner, urCorner, llCorner }; srcRect = new Rectangle(shadow.Width - 6, 0, 6, shadow.Height - 6); g.DrawImage(shadow, destPara, srcRect, units); //Draw the shadow's bottom hand side ulCorner = new Point(rightMargin, fullImage.Height - 6); urCorner = new Point(fullImage.Width - 6, fullImage.Height - 6); llCorner = new Point(rightMargin, fullImage.Height); destPara = new Point[] { ulCorner, urCorner, llCorner }; srcRect = new Rectangle(0, shadow.Height - 6, shadow.Width - 6, 6); g.DrawImage(shadow, destPara, srcRect, units); return fullImage; }
public static Texture2D CreateTexture2DFromBitmap(Device device, BitmapSource bitmapSource) { // Allocate DataStream to receive the WIC image pixels int stride = bitmapSource.Size.Width * 4; using (var buffer = new SharpDX.DataStream(bitmapSource.Size.Height * stride, true, true)) { // Copy the content of the WIC to the buffer bitmapSource.CopyPixels(stride, buffer); return new SharpDX.Direct3D11.Texture2D(device, new SharpDX.Direct3D11.Texture2DDescription() { Width = bitmapSource.Size.Width, Height = bitmapSource.Size.Height, ArraySize = 1, BindFlags = SharpDX.Direct3D11.BindFlags.ShaderResource, Usage = SharpDX.Direct3D11.ResourceUsage.Immutable, CpuAccessFlags = SharpDX.Direct3D11.CpuAccessFlags.None, Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm, MipLevels = 1, OptionFlags = SharpDX.Direct3D11.ResourceOptionFlags.None, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), }, new SharpDX.DataRectangle(buffer.DataPointer, stride)); } }
private static DataStream GetPixels(BitmapSource source, int stride) { var pixels = new DataStream(source.Size.Height * stride, true, true); source.CopyPixels(stride, pixels); return pixels; }
private void CalculateLuminanceBGR(BitmapSource bitmap) { var width = bitmap.PixelWidth; var height = bitmap.PixelHeight; var stepX = (bitmap.Format.BitsPerPixel + 7) / 8; var bufferSize = width * stepX; var buffer = new byte[bufferSize]; var rect = new Int32Rect(0, 0, width, 1); var luminanceIndex = 0; for (var curY = 0; curY < height; curY++) { bitmap.CopyPixels(rect, buffer, bufferSize, 0); for (var curX = 0; curX < bufferSize; curX += stepX) { var b = buffer[curX]; var g = buffer[curX + 1]; var r = buffer[curX + 2]; luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); luminanceIndex++; } rect.Y++; } }
/// <summary> /// Initializes a new instance of the <see cref="XImage"/> class from a WinRT image. /// </summary> XImage(BitmapSource image) { _wrtImage = image; Initialize(); }
private void CalculateLuminanceBGR565(BitmapSource bitmap) { var width = bitmap.PixelWidth; var height = bitmap.PixelHeight; var stepX = (bitmap.Format.BitsPerPixel + 7) / 8; var bufferSize = width * stepX; var buffer = new byte[bufferSize]; var rect = new Int32Rect(0, 0, width, 1); var luminanceIndex = 0; for (var curY = 0; curY < height; curY++) { bitmap.CopyPixels(rect, buffer, bufferSize, 0); for (var curX = 0; curX < bufferSize; curX += stepX) { var byte1 = buffer[curX]; var byte2 = buffer[curX + 1]; var b5 = byte1 & 0x1F; var g5 = (((byte1 & 0xE0) >> 5) | ((byte2 & 0x03) << 3)) & 0x1F; var r5 = (byte2 >> 2) & 0x1F; var r8 = (r5 * 527 + 23) >> 6; var g8 = (g5 * 527 + 23) >> 6; var b8 = (b5 * 527 + 23) >> 6; // cheap, not fully accurate conversion //var pixel = (byte2 << 8) | byte1; //b8 = (((pixel) & 0x001F) << 3); //g8 = (((pixel) & 0x07E0) >> 2) & 0xFF; //r8 = (((pixel) & 0xF800) >> 8); luminances[luminanceIndex] = (byte)((RChannelWeight * r8 + GChannelWeight * g8 + BChannelWeight * b8) >> ChannelWeight); luminanceIndex++; } rect.Y++; } }
private void UpdateImage(double west, double east, double south, double north, BitmapSource image) { currentImageIndex = (currentImageIndex + 1) % 2; var mapImage = (MapImage)Children[currentImageIndex]; mapImage.Source = null; mapImage.North = double.NaN; // avoid frequent MapRectangle.UpdateData() calls mapImage.West = west; mapImage.East = east; mapImage.South = south; mapImage.North = north; if (image != null) { mapImage.Source = image; AddDownloadEventHandlers(image); } else { BlendImages(); } }
unsafe void InitializeFont(GDIFont font) { IntPtr hdc = myTempGraphics.GetHdc(); IntPtr hfont = font.ToHfont(); SelectObject(hdc, hfont); if (!GetCharWidth32(hdc, 0, 255, CharacterWidths)) throw new SystemException("Unable to measure character widths."); tagTEXTMETRIC metrics = new tagTEXTMETRIC(); GetTextMetrics(hdc, ref metrics); myLeadingSpace = metrics.tmInternalLeading; myTrailingSpace = metrics.tmExternalLeading; myTempGraphics.ReleaseHdc(hdc); int width = 0; for (int i = myFirstCharacterOfInterest; i <= myLastCharacterOfInterest; i++) { CharacterWidths[i] += myLeadingSpace + myTrailingSpace; width += CharacterWidths[i]; } myHeight = (int)Math.Round(myTempGraphics.MeasureString(myCharactersOfInterest, font).Height); int squareDim = (int)Math.Ceiling(Math.Sqrt(width * myHeight)); squareDim = BitmapSource.GetValidTextureDimensionFromSize(squareDim); int squareWidth = squareDim; int squareHeight = squareDim; float fSquareWidth = squareWidth; float fSquareHeight = squareHeight; Bitmap bitmap; bool fit; do { bitmap = new Bitmap(squareWidth, squareHeight, System.Drawing.Imaging.PixelFormat.Format16bppRgb565); using (Graphics g = Graphics.FromImage(bitmap)) { int x = 0; int y = 0; for (char i = myFirstCharacterOfInterest; i <= myLastCharacterOfInterest; i++) { if (x + CharacterWidths[i] >= fSquareWidth) { y += myHeight; x = 0; } CharacterLocations[i] = new Point(x, y); float uStart = x / fSquareWidth; float uEnd = (x + CharacterWidths[i]) / fSquareWidth; float vStart = y / fSquareHeight; float vEnd = (y + myHeight) / fSquareHeight; int offset = i * 4; TextureCoordinates[offset] = new TextureCoordinate(uStart, vEnd); TextureCoordinates[offset+ 1] = new TextureCoordinate(uStart, vStart); TextureCoordinates[offset + 2] = new TextureCoordinate(uEnd, vEnd); TextureCoordinates[offset + 3] = new TextureCoordinate(uEnd, vStart); g.DrawString(i.ToString(), font, myWhiteBrush, x, y); // adding a 1 pixel extra margin on the left seems to clear up some artifacting // that occurs as a result of glyphs being too close together. x += CharacterWidths[i] + 1; } fit = y + myHeight < fSquareHeight; if (!fit) { squareWidth <<= 1; fSquareWidth = squareWidth; } } } while (!fit); byte[] alphaBytes = new byte[bitmap.Width * bitmap.Height]; BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format16bppRgb565); int pixCount = 0; for (int y = 0; y < bitmap.Height; y++) { short* yp = (short*)((int)data.Scan0 + data.Stride * y); for (int x = 0; x < bitmap.Width; x++, pixCount++) { short* p = (short*)(yp + x); short pixel = *p; byte b = (byte)((pixel & 0x1F) << 3); byte g = (byte)(((pixel >> 5) & 0x3F) << 2); byte r = (byte)(((pixel >> 11) & 0x1F) << 3); byte totalAlpha = (byte)((r + g + b) / 3); alphaBytes[pixCount] = totalAlpha; } } bitmap.UnlockBits(data); bitmap.Dispose(); uint tex = 0; gl.GenTextures(1, &tex); gl.BindTexture(gl.GL_TEXTURE_2D, tex); fixed (byte* alphaBytesPointer = alphaBytes) { gl.TexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_ALPHA, squareWidth, squareHeight, 0, gl.GL_ALPHA, gl.GL_UNSIGNED_BYTE, (IntPtr)alphaBytesPointer); } gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE); gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE); mySource = new BitmapSource(); mySource.myWidth = squareWidth; mySource.myHeight = squareHeight; mySource.myName = tex; mySource.myIsTransparent = true; }
protected void UpdateImage(double west, double east, double south, double north, BitmapSource bitmap) { currentImageIndex = (currentImageIndex + 1) % 2; var mapImage = (MapImage)Children[currentImageIndex]; mapImage.SetBoundingBox(west, east, south, north); mapImage.Source = bitmap; ImageUpdated(bitmap); }
/// <summary> /// Conversion from BitmapSource to XImage. /// </summary> public static XImage FromBitmapSource(BitmapSource image) { return new XImage(image); }
/// <summary> /// Gets the image filename. /// </summary> /// <param name="bitmapSource">The bitmap source.</param> internal static string GetImageFilename(BitmapSource bitmapSource) { string filename = bitmapSource.ToString(); filename = UrlDecodeStringFromStringInternal(filename); if (filename.StartsWith("file:///")) filename = filename.Substring(8); // Remove all 3 slashes! else if (filename.StartsWith("file://")) filename = filename.Substring(5); // Keep 2 slashes (UNC path) return filename; }
public WicBitmapSource(ImagingFactory factory, BitmapSource wicImpl) { this.factory = factory; this.WicImpl = wicImpl; }
private static Texture2D CreateTexture2DFromBitmapSource(Device device, BitmapSource bitmapSource, TextureLoadOptions options) { // Allocate DataStream to receive the WIC image pixels var stride = bitmapSource.Size.Width * 4; using (var buffer = new DataStream(bitmapSource.Size.Height * stride, true, true)) { // Copy the content of the WIC to the buffer bitmapSource.CopyPixels(stride, buffer); var texture2DDescription = new Texture2DDescription() { Width = bitmapSource.Size.Width, Height = bitmapSource.Size.Height, ArraySize = 1, BindFlags = options.BindFlags, Usage = options.ResourceUsage, CpuAccessFlags = options.CpuAccessFlags, Format = options.Format, MipLevels = options.MipLevels, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), }; bitmapSource.Dispose(); var dataRectangle = new DataRectangle(buffer.DataPointer, stride); return new Texture2D(device, texture2DDescription, dataRectangle); } }
protected override void DrawVisualThumbnail(DrawingContext drawingContext, out string title, ref BitmapSource icon) { var aeroColor = (Color)Application.Current.Resources["AeroColor"]; var aeroBrush = new SolidColorBrush(aeroColor); var aeroPen = new Pen(aeroBrush, 7); var grayBrush = new SolidColorBrush(Color.FromArgb(255, 0xaf, 0xaf, 0xaf)); var fileIcon = Icon; var parentLocationIcon = (BitmapSource) Application.Current.Resources["FileClipboardItemParentLocationIcon"]; var fontFamily = (FontFamily)Application.Current.Resources["CuprumFont"]; var typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Light, FontStretches.Normal); const int fileNameTextOffset = VisualThumbnailMargin + 32 + VisualThumbnailMargin / 2; const int parentLocationTextOffset = VisualThumbnailMargin + 16 + VisualThumbnailMargin/2; var fileNameText = new FormattedText(Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 18, aeroBrush); fileNameText.MaxTextWidth = VisualThumbnailWidth - fileNameTextOffset - VisualThumbnailMargin; fileNameText.MaxTextHeight = 32; if (!string.IsNullOrEmpty(ParentLocation)) { var parentLocationText = new FormattedText(ParentLocation, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 14, grayBrush); parentLocationText.MaxTextWidth = VisualThumbnailWidth - parentLocationTextOffset - VisualThumbnailMargin; parentLocationText.MaxTextHeight = 32; drawingContext.DrawImage(parentLocationIcon, new Rect(VisualThumbnailMargin, VisualThumbnailMargin + 32 + VisualThumbnailMargin, 16, 16)); drawingContext.DrawText(parentLocationText, new Point(parentLocationTextOffset, VisualThumbnailMargin + 32 + VisualThumbnailMargin)); } drawingContext.DrawRectangle(Brushes.White, aeroPen, new Rect(-1, -1, VisualThumbnailWidth + 2, VisualThumbnailHeight + 2)); drawingContext.DrawImage(fileIcon, new Rect(VisualThumbnailMargin, VisualThumbnailMargin, 32, 32)); drawingContext.DrawText(fileNameText, new Point(fileNameTextOffset, VisualThumbnailMargin + fileNameText.MaxTextHeight / 2 - fileNameText.Height / 2)); title = Name; }
private Texture2D CreateDirectXTexture(BitmapSource source) { var stride = source.Size.Width * 4; using (var buffer = GetPixels(source, stride)) return new Texture2D(device.NativeDevice, CreateTextureDescription(source.Size), new DataRectangle(buffer.DataPointer, stride)); }
//TODO: factory? protected abstract void DrawVisualThumbnail(DrawingContext drawingContext, out string title, ref BitmapSource icon);
/// <summary> /// Add another frame /// </summary> /// <param name="nextFrame">The next frame</param> public void Add(BitmapSource nextFrame) { var jbe = new JpegBitmapEncoder(); jbe.QualityLevel = 100; jbe.Frames.Add(BitmapFrame.Create(nextFrame)); jbe.Save(vs); }
private static FormatConverter Convert(ImagingFactory factory, BitmapSource source) { var formatConverter = new FormatConverter(factory); formatConverter.Initialize(source, PixelFormat.Format32bppPRGBA, BitmapDitherType.None, null, 0.0, BitmapPaletteType.Custom); return formatConverter; }
public void DrawImage(BitmapSource imageSource, Rect rect) { RectangleGeometry geo = new RectangleGeometry(rect); ImageBrush brush = new ImageBrush(); brush.ImageSource = imageSource; brush.Stretch = Stretch.Fill; DrawGeometry(brush, null, geo); }