RQD*_*QDQ 59
您是否尝试过旋转用户控件的实例并执行以下操作:
UserControl control = new UserControl1();
control.Measure(new Size(300, 300));
control.Arrange(new Rect(new Size(300,300)));
RenderTargetBitmap bmp = new RenderTargetBitmap(300, 300, 96, 96, PixelFormats.Pbgra32);
bmp.Render(control);
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
using (Stream stm = File.Create(@"c:\test.png"))
encoder.Save(stm);
Run Code Online (Sandbox Code Playgroud)
看起来你需要测量,安排.这对我有用.
使用没有实际窗口的HwndHost结束.
void cwind()
{
Application myapp = new Application();
mrenderer = new WPFRenderer();
mrenderer.Width = 256;
mrenderer.Height = 256;
HwndSourceParameters myparms = new HwndSourceParameters();
HwndSource msrc = new HwndSource(myparms);
myparms.HwndSourceHook = new HwndSourceHook(ApplicationMessageFilter);
msrc.RootVisual = mrenderer;
myapp.Run();
}
static IntPtr ApplicationMessageFilter(
IntPtr hwnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
{
return IntPtr.Zero;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
22400 次 |
最近记录: |