public void DrawContent(EditView view,bool IsEnabled,Rectangle updateRect)
{
SharpDX.Mathematics.Interop.RawPoint offset;
+ //デバイス依存の座標を渡さないといけない
this.Surface = this.SurfaceImageNative.BeginDraw(
- new SharpDX.Rectangle(0, 0, (int)this.Size.Width, (int)this.Size.Height), out offset);
+ new SharpDX.Rectangle(0, 0, (int)(this.Size.Width * this.GetScale()), (int)(this.Size.Height * this.GetScale())), out offset);
var prop = new D2D.BitmapProperties1();
prop.BitmapOptions = D2D.BitmapOptions.Target | D2D.BitmapOptions.CannotDraw | D2D.BitmapOptions.GdiCompatible;
prop.PixelFormat = this._RenderTargetProperties.PixelFormat;
- prop.DpiX = this._RenderTargetProperties.DpiX;
- prop.DpiY = this._RenderTargetProperties.DpiY;
+ //prop.DpiX = this._RenderTargetProperties.DpiX;
+ //prop.DpiY = this._RenderTargetProperties.DpiY;
this.Bitmap = new D2D.Bitmap1(this.D2DContext, this.Surface, null);
this.D2DContext.Target = this.Bitmap;
- this.D2DContext.Transform = Matrix3x2.Translation(offset.X, offset.Y);
+ //こっちはDirect2Dなのでデバイス非依存の座標を渡す
+ float dipOffsetX = (float)(offset.X / this.GetScale());
+ float dipOffsetY = (float)(offset.Y / this.GetScale());
+ this.D2DContext.Transform = Matrix3x2.Translation(dipOffsetX, dipOffsetY);
base.BegineDraw();
if (IsEnabled)
{
if (this.SurfaceImageNative != null)
this.SurfaceImageNative.Dispose();
- this.SurfaceImage = new SurfaceImageSource((int)width, (int)height);
+ //デバイス依存の座標を渡さないといけない
+ this.SurfaceImage = new SurfaceImageSource((int)(width * this.GetScale()), (int)(height * this.GetScale()), false);
this.SurfaceImageNative = ComObject.As<DXGI.ISurfaceImageSourceNative>(this.SurfaceImage);
this.SurfaceImageNative.Device = this.DXGIDevice;
this.Size.Width = width;
{
this.D2DDevice = new D2D.Device(factory,this.DXGIDevice);
this.D2DContext = new D2D.DeviceContext(this.D2DDevice, D2D.DeviceContextOptions.None);
+ this.D2DContext.DotsPerInch = new Size2F(prop.DpiX, prop.DpiY);
this._RenderTargetProperties = prop;
return this.D2DContext;
}