printing under MFC & VC++ 6.0

jnorris at uiuc.edu jnorris at uiuc.edu
Fri Jun 18 11:22:40 EDT 1999


Once upon a time, Ben Held wrote:
> Hello,
> 
> I cannot seem to get printing or clipboard copying to work using Visual C++
> 6.0 on Windows NT and VTK 2.3.  Even the example project UGVIEW2 does not
> work.  Both printing and clipboard copying produce an empty black box.  Has
> anyone solved this problem?
> 
> Thanks,
> 
> Ben

Hi Ben,

I can't help you with your printing problem, but I can show you how I finally
managed to copy the contents of the Vtk window to the clipboard.

void CMyView::OnEditCopy() 
{
	if (OpenClipboard()) {
		int *size = renwin->GetSize();

		unsigned char *data = renwin->GetPixelData(0, 0, size[0]-1, size[1]-1, 1);

		CDC *pDC = GetDC();
		CBitmap bitmap;
		bitmap.CreateCompatibleBitmap(pDC, size[0], size[1]);

		unsigned long *bits = new unsigned long[size[0] * size[1]];
		int i, j, k;
		for (j=0; j<size[1]; j++) {
			for (i=0; i<size[0]; i++) {
				k = 3 * ((size[1] - j - 1) * size[0] + i);
				bits[j*size[0]+i] = RGB(data[k+2], data[k+1], data[k]);
			}
		}
		bitmap.SetBitmapBits(size[0] * size[1] * 4, (void *)bits);
		delete []bits;

		EmptyClipboard();
		SetClipboardData(CF_BITMAP, bitmap);
		CloseClipboard();
		bitmap.DeleteObject();
		ReleaseDC(pDC);
	}
}

Hope this helps,
John
-- 
John Norris
Center for Simulation of Advanced Rockets
jnorris at uiuc.edu
http://www.uiuc.edu/ph/www/jnorris


-----------------------------------------------------------------------------
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