private void testDraw() { CadSize2D deviceSize = new CadSize2D(827, 1169); CadSize2D pageSize = new CadSize2D(210, 297); DrawContext dc = Controller.DC.CreatePrinterContext(pageSize, deviceSize); dc.SetupTools(DrawTools.DrawMode.PRINTER); FrameBufferW fb = new FrameBufferW(); fb.Create((int)deviceSize.Width, (int)deviceSize.Height); fb.Begin(); dc.StartDraw(); dc.Drawing.Clear(dc.GetBrush(DrawTools.BRUSH_BACKGROUND)); Controller.DrawFiguresRaw(dc); dc.EndDraw(); Bitmap bmp = fb.GetBitmap(); fb.End(); fb.Dispose(); bmp.Save(@"F:\work\test2.bmp"); }
private static Bitmap GetPrintableBmp(PlotterController pc, CadSize2D pageSize, CadSize2D deviceSize) { if (!(pc.DC is DrawContextGL)) { return(null); } DrawContext dc = pc.DC.CreatePrinterContext(pageSize, deviceSize); dc.SetupTools(DrawTools.DrawMode.PRINTER); // Bitmapを印刷すると大きさが変わるので、補正 double f = SettingsHolder.Settings.MagnificationBitmapPrinting; dc.UnitPerMilli *= f; //dc.UnitPerMilli *= 0.96; Vector3d org = dc.ViewOrg; //org *= 0.96; org *= f; dc.SetViewOrg(org); FrameBufferW fb = new FrameBufferW(); fb.Create((int)deviceSize.Width, (int)deviceSize.Height); fb.Begin(); dc.StartDraw(); GL.Disable(EnableCap.LineSmooth); dc.Drawing.Clear(dc.GetBrush(DrawTools.BRUSH_BACKGROUND)); pc.DrawFiguresRaw(dc); GL.Enable(EnableCap.LineSmooth); dc.EndDraw(); Bitmap bmp = fb.GetBitmap(); fb.End(); fb.Dispose(); return(bmp); }