D2D.Device D2DDevice;
D2D.DeviceContext D2DContext;
D2D.Bitmap1 Bitmap;
- int dpi;
Size Size;
- public D2DPrintPreviewRender(string fontName, double fontSize, Size size, uint dpi)
+ public D2DPrintPreviewRender(string fontName, double fontSize, Size size)
: base()
{
this.Size = size;
- this.dpi = (int)dpi;
-
base.ConstructRender = this.ConstructRenderHandler;
base.ConstrctedResource = this.ConstructedResourceHandler;
base.DestructRender = this.DestructRenderHandler;
new void GetDpi(out float dpix, out float dpiy)
{
- dpix = this.dpi;
- dpiy = this.dpi;
+ dpix = (int)DisplayProperties.LogicalDpi;
+ dpiy = (int)DisplayProperties.LogicalDpi;
}
public override void BeginDraw()
{
- this.ReConstructDeviceResource(this.Size.Width,this.Size.Height); //再構築しないとごみが残る
base.BeginDraw();
}
+ public void Resize(float width,float height)
+ {
+ this.ReConstructDeviceResource(width, height);
+ }
+
public override void EndDraw()
{
throw new NotImplementedException();
public void EndDraw(IPrintPreviewDxgiPackageTarget target,uint page)
{
base.EndDraw();
- target.DrawPage(page, this.Surface.NativePointer, (float)this.dpi, (float)this.dpi);
+ float dpix, dpiy;
+ this.GetDpi(out dpix, out dpiy);
+
+ target.DrawPage(page, this.Surface.NativePointer, (float)dpix, (float)dpiy);
}
- public void SetScale(double scale)
+ public void SetScale(float scale)
{
- this.D2DContext.Transform = Matrix3x2.Scaling((float)scale);
+ this.D2DContext.Transform = Matrix3x2.Scaling(1/scale);
}
D2D.RenderTarget ConstructRenderHandler(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
{
+ float dpix, dpiy;
+ this.GetDpi(out dpix, out dpiy);
+
D3D11.Texture2DDescription desc = new D3D11.Texture2DDescription();
- desc.Width = (int)(width * dpi / 96);
- desc.Height = (int)(height * dpi / 96);
+ desc.Width = (int)(width * dpix / 96);
+ desc.Height = (int)(height * dpix / 96);
desc.Format = DXGI.Format.B8G8R8A8_UNorm;
desc.BindFlags = D3D11.BindFlags.RenderTarget | D3D11.BindFlags.ShaderResource;
desc.ArraySize = 1;
this.D2DContext = new D2D.DeviceContext(this.D2DDevice, D2D.DeviceContextOptions.None);
- this.D2DContext.DotsPerInch = new Size2F(this.dpi, this.dpi);
+ this.D2DContext.DotsPerInch = new Size2F(dpix, dpix);
D2D.BitmapProperties1 bmpProp = new D2D.BitmapProperties1();
bmpProp.BitmapOptions = D2D.BitmapOptions.Target | D2D.BitmapOptions.CannotDraw;