in Education by
I want to save an image from my WPF user control. It works but I got black bars on the right side and the bottom. If I change the dpiX (96) and dpiY (96) it works but when I maximize the window, it's wrong again (then a bit of the usercontrol is missing ). This is how I save the image as bitmap: Dim parentWindow As Window = Window.GetWindow(_Map) Dim rtb As New RenderTargetBitmap(parentWindow.ActualWidth, parentWindow.ActualHeight, 96, 96, PixelFormats.Pbgra32) rtb.Render(_Map) Dim ms As New MemoryStream() Dim bp As New BmpBitmapEncoder() bp.Frames.Add(BitmapFrame.Create(rtb)) bp.Save(ms) Dim saveMap As New Bitmap(ms) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The width and height of the window are a bit larger than your UserControl because it includes the titlebar and borders. if you use the dimensions of your control instead it works fine: Dim rtb As New RenderTargetBitmap(_Map.ActualWidth, _Map.ActualHeight, 96, 96, PixelFormats.Pbgra32) I recommend you also make sure the control is layouted properly by calling Measure and Arrange with the current or desired size before rendering. Additional size calculations may be neccessary if you are using the LayoutTransform or RenderTransform properties of your control. Btw: WPF always uses 96 DPI for size calculations so you shouldn't change that.

Related questions

0 votes
    I want to save an image from my WPF user control. It works but I got black bars on the right ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I want to save an image from my WPF user control. It works but I got black bars on the right ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I've created a semi-transparent test image, filled with 128-alpha black. I draw it while alternating ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    My application has many views and I am using an AutoLogoffHelper class which maintains the timer for the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    Which of the following bars contains commands such as open, save, copy and paste? a) Side bar b) Status ... d) Formatting Toolbar Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Which of the following bars contains commands such as open, save, copy and paste? a) Side bar b) Status ... d) Formatting Toolbar Select the correct answer from above options...
asked Dec 18, 2021 in Education by JackTerrance
0 votes
    C. Choose the right option: 1. The bottom margins and top of a document can be changed by using the . a ... indent c. Increase indent Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    Where will you find the Home tab in Windows Movie Maker?. * a.Bottom corner b. Right corner c. Left top corner 2. ... b. .wav c. .jpg Select the correct answer from above options...
asked Dec 16, 2021 in Education by JackTerrance
0 votes
    ….is a right hand side of the accounts in double entry system Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    Sometimes the side of concrete bridges is observed to turn black in colour. What is the reason for this phenomenon?...
asked Jan 1, 2021 in Technology by JackTerrance
0 votes
    I've found the following CSS code that I pasted in the child theme's css stylesheet, but it doesn ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I've found the following CSS code that I pasted in the child theme's css stylesheet, but it doesn ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    You can create your own style by clicking on the __________ button located at the bottom of style pane. * a.style ... d.none of these Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    Header are the text images included _____ on the page in word processor. A. top B. bottom C. both A&B Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    This question already has answers here: Order Bars in ggplot2 bar graph (14 answers) Closed 3 years ago. I ... -interventions", "Compliance", "Timing of outcome assessments" data...
asked Jun 1, 2022 in Education by JackTerrance
...