i want save image wpf user control. works got black bars on right side , bottom. if change dpix (96) , dpiy (96) works when maximize window, it's wrong again (then bit of usercontrol missing ).
this how save image bitmap:
dim parentwindow window = window.getwindow(_map) dim rtb new rendertargetbitmap(parentwindow.actualwidth, parentwindow.actualheight, 96, 96, pixelformats.pbgra32) rtb.render(_map) dim ms new memorystream() dim bp new bmpbitmapencoder() bp.frames.add(bitmapframe.create(rtb)) bp.save(ms) dim savemap new bitmap(ms)
the width , height of window bit larger usercontrol because includes titlebar , borders. if use dimensions of control instead works fine:
dim rtb new rendertargetbitmap(_map.actualwidth, _map.actualheight, 96, 96, pixelformats.pbgra32)
i recommend make sure control layouted calling measure
, arrange
current or desired size before rendering.
additional size calculations may neccessary if using layouttransform
or rendertransform
properties of control.
btw: wpf uses 96 dpi size calculations shouldn't change that.
Comments
Post a Comment