vtk & MFC: saving as bitmap using vtkWin32MappedInteractor::SaveBMP()

Klaus Nowikow knowikow at iac.tuwien.ac.at
Wed Aug 18 09:20:39 EDT 1999


Dear vtkusers,

in my applycation I am trying to save bitmaps using
vtkWin32MappedInteractor::SaveBMP().

All I get is a white rectangle, and even worse, my render window is also
empty after this procedure.
My code looks like that:

In my View class (CCommon3DView), I defined the following member
variables:

vtkWin32OpenGLRenderWindow      *window;
vtkWin32MappedInteractor        *interactor;
vtkRenderer                     *renderer;

then:

int CCommon3DView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
        if (CView::OnCreate(lpCreateStruct) == -1)
                return -1;

        this->renderer = vtkRenderer::New();
        this->window = vtkWin32OpenGLRenderWindow::New();
        this->window->AddRenderer(this->renderer);
        this->window->SwapBuffersOn();
        this->interactor = vtkWin32MappedInteractor::New();
        this->interactor->SetRenderWindow(this->window);

        /* --- [snip] ---*/

        return 0;
}

and:

void CCommon3DView::OnDraw(CDC* pDC)
{
        if(!this->interactor->GetInitialized())
        {
                CRect   rect;

                /* --- [snip] ---*/
                camera = this->renderer->GetActiveCamera();
                this->GetClientRect(&rect);
                this->interactor->Initialize(this->m_hWnd, &rect,
this->window);
                this->renderer->ResetCamera();
        }
        
        camera = this->renderer->GetActiveCamera();

        if(pDC->IsPrinting())
        {
                this->BeginWaitCursor();
                // get size of printer page (in pixels)
                int cxPage = pDC->GetDeviceCaps(HORZRES);
                int cyPage = pDC->GetDeviceCaps(VERTRES);

                int     *size = this->window->GetSize();
                int     cxWindow = size[0],
                        cyWindow = size[1];

                float   fx = float(cxPage) / float(cxWindow),
                                fy = float(cyPage) / float(cyWindow);
                float   scale = min(fx, fy);
                int     x = int(scale * float(cxWindow)),
                        y = int(scale * float(cyWindow));

                this->window->SetupMemoryRendering(cxWindow, cyWindow,
pDC->GetSafeHdc());
                this->window->Render();

                HDC     memDC = this->window->GetMemoryDC();

                StretchBlt(pDC->GetSafeHdc(), 0, 0, x, y, memDC, 0, 0,
cxWindow,
cyWindow, SRCCOPY);
                this->window->ResumeScreenRendering();
                this->EndWaitCursor();
        }
        else
        {
                this->interactor->Update();
        }
}

and:

void CCommon3DView::OnFileSaveAs() 
{
	CString	path;
	/* --- [snip] ---*/
	this->interactor->SaveBMP(LPCTSTR(path), 300, 300, 24);
}

Any suggestions?
Thanks in advance
-- 
 Klaus Nowikow

 Vienna University of Technology
 Department of Analytical Chemistry
 Getreidemarkt 9/E151
 A - 1060 Vienna, Austria
 Tel:   +43/1/58801 - 15124
 email: mailto:knowikow at iac.tuwien.ac.at


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list