뷰포트 스크린 캡처
C++, .NET
Summary: Rhino SDK 를 사용하여 뷰포트를 스크린 캡처하는 방법을 소개합니다.
참보
질문
ViewCaptureToFile 명령처럼, 어느 한 뷰포트를 스크린 캡처하여 파일로 저장하고 싶습니다.
답변
Rhino 의 ViewCaptureToFile 명령은 일반적인 스크린 캡처를 실행하지 않습니다. 오히려, (뷰포트가 아닌) 장치에 비종속적인 비트맵 (DIB) 에 지오메트리를 그리고 디스크에 저장하는 것입니다.
질문하신 내용을 실행하려면 다음의 샘플 코드를 참조하세요.
C++
CRhinoCommand::result CCommandTest::RunCommand( const CRhinoCommandContext& context ) { CWnd* pMainWnd = CWnd::FromHandle( RhinoApp().MainWnd() ); if( 0 == pMainWnd ) return failure; CRhinoGetFileDialog gf; gf.SetScriptMode( context.IsInteractive() ? FALSE : TRUE ); BOOL rc = gf.DisplayFileDialog( CRhinoGetFileDialog::save_bitmap_dialog, 0, pMainWnd ); if( !rc ) return cancel; ON_wString filename = gf.FileName(); filename.TrimLeftAndRight(); if( filename.IsEmpty() ) return nothing; CRhinoView* view = RhinoApp().ActiveView(); if( view ) { CRect rect; view->GetClientRect( rect ); CRhinoDib dib; if( dib.CreateDib(rect.Width(), rect.Height(), 24, true) ) { // Set these flags as you wish. BOOL bIgnoreHighlights = TRUE; BOOL bDrawTitle = FALSE; BOOL bDrawConstructionPlane = FALSE; BOOL bDrawWorldAxes = FALSE; CRhinoObjectIterator it( CRhinoObjectIterator::normal_or_locked_objects, CRhinoObjectIterator::active_and_reference_objects ); if( view->ActiveViewport().DisplayMode() == ON::wireframe_display ) { context.m_doc.DrawToDC( it, dib, dib.Width(), dib.Height(), view->ActiveViewport().View(), bIgnoreHighlights, bDrawTitle, bDrawConstructionPlane, bDrawWorldAxes ); } else { context.m_doc.RenderToDC( it, dib, dib.Width(), dib.Height(), view->ActiveViewport().View(), bIgnoreHighlights, bDrawTitle, bDrawConstructionPlane, bDrawWorldAxes, view->ActiveViewport().GhostedShade() ); } dib.WriteToFile( filename ); } } return success; }
VB.NET