Note that there are some explanatory texts on larger screens.

plurals
  1. PORenderTargetBitmap is blurry
    primarykey
    data
    text
    <p>Hi i'm creating an image in memory from a Canvas using a PngBitmapEncoder. </p> <pre><code>public void CaptureGraphic() { Canvas canvas = new Canvas(); canvas.SnapsToDevicePixels = true; canvas.Height = IMAGEHEIGHT; canvas.Width = IMAGEWIDTH; Draw(canvas); canvas.Arrange(new Rect(0, 0, IMAGEWIDTH, IMAGEHEIGHT)); member.MemberImage = GetPngFromUIElement(canvas); } public static System.Drawing.Image GetPngFromUIElement(Canvas source) { int width = (int)source.ActualWidth; int height = (int)source.ActualHeight; if (width == 0) width = (int)source.Width; if (height == 0) height = (int)source.Height; RenderTargetBitmap bitmap = new RenderTargetBitmap(width, height, 96d, 96d, PixelFormats.Pbgra32); bitmap.Render(source); PngBitmapEncoder enc = new PngBitmapEncoder(); enc.Interlace = PngInterlaceOption.Off; enc.Frames.Add(BitmapFrame.Create(bitmap)); System.IO.MemoryStream ms = new System.IO.MemoryStream(); enc.Save(ms); System.Drawing.Image image = System.Drawing.Image.FromStream(ms); ms.Flush(); ms.Dispose(); return image; } </code></pre> <p>Then i'm sending the image to the printer using the GDI+ DrawImage() method. However the printed result is blurry.</p> <p>I've tried to match the original canvas size to the printed size to avoid any scaling, equally i've tried to make the original considerably bigger so the scaled image retains the quality however the final printed image is always blurred.</p> <p>Can anyone offer any suggestions/alternatives. I have a considerable GDI+ print routine already setup and moving to wpf documents is not an option just yet.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload