void CPixelBufferView::OnSaveBitmap()
{
	auto pixelBuffer = GetSelectedPixelBuffer();
	if(!pixelBuffer) return;
	auto pixelBufferBitmap = pixelBuffer->second;

	auto bpp = pixelBufferBitmap.GetBitsPerPixel();
	if((bpp == 24) || (bpp == 32))
	{
		pixelBufferBitmap = ConvertBGRToRGB(std::move(pixelBufferBitmap));
	}

	Framework::Win32::CFileDialog openFileDialog;
	openFileDialog.m_OFN.lpstrFilter = _T("Windows Bitmap Files (*.bmp)\0*.bmp");
	int result = openFileDialog.SummonSave(m_hWnd);
	if(result == IDOK)
	{
		try
		{
			auto outputStream = Framework::CreateOutputStdStream(std::tstring(openFileDialog.m_OFN.lpstrFile));
			Framework::CBMP::WriteBitmap(pixelBufferBitmap, outputStream);
		}
		catch(const std::exception& exception)
		{
			auto message = string_format("Failed to save buffer to file:\r\n\r\n%s", exception.what());
			MessageBoxA(m_hWnd, message.c_str(), nullptr, MB_ICONHAND);
		}
	}
}
Example #2
0
void CMainWindow::RecordAvi()
{
	if(m_recordingAvi)
	{
		m_recordingAvi = false;

		while(1)
		{
			DWORD result = MsgWaitForMultipleObjects(1, &m_recordAviMutex, FALSE, INFINITE, QS_ALLINPUT);
			if(result == WAIT_OBJECT_0) break;
			MSG msg;
			GetMessage(&msg, NULL, 0, 0);
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		
		{
			m_aviStream.Close();
			delete [] m_recordBuffer;
			m_recordBuffer = NULL;
			m_recordBufferWidth = 0;
			m_recordBufferHeight = 0;
		}
		ReleaseMutex(m_recordAviMutex);

		UpdateUI();
	}
	else
	{
		CScopedVmPauser vmPauser(m_virtualMachine);

		Framework::Win32::CFileDialog d;
		d.m_OFN.lpstrFilter = _T("AVI Movie Files (*.avi)\0*.avi\0All files (*.*)\0*.*\0");
		if(!d.SummonSave(m_hWnd))
		{
			return;
		}

		RECT rc = m_outputWnd->GetWindowRect();
		unsigned int nViewW = rc.right - rc.left;
		unsigned int nViewH = rc.bottom - rc.top;

		m_aviStream.SetSize(nViewW, nViewH);
		if(!m_aviStream.Open(m_hWnd, d.GetPath()))
		{
			MessageBox(m_hWnd, _T("Failed to start AVI recording."), APP_NAME, 16);
			return;
		}

		m_recordBufferWidth = nViewW;
		m_recordBufferHeight = nViewH;
		m_recordBuffer = new uint8[m_recordBufferWidth * m_recordBufferHeight * 4];

		m_recordingAvi = true;
		UpdateUI();
	}
}
Example #3
0
void CMainWindow::OnPlaylistSaveClick()
{
	Framework::Win32::CFileDialog dialog;
	const TCHAR* filter = PLAYLIST_FILTER;
	dialog.m_OFN.lpstrFilter = filter;
	dialog.m_OFN.lpstrDefExt = PLAYLIST_EXTENSION + 1;
	if(dialog.SummonSave(m_hWnd))
	{
		try
		{
			m_playlist.Write(dialog.GetPath());
		}
		catch(const std::exception& except)
		{
			std::tstring errorString = _T("Couldn't save playlist: \r\n\r\n");
			errorString += string_cast<std::tstring>(except.what());
			MessageBox(m_hWnd, errorString.c_str(), NULL, 16);
		}
	}
}
Example #4
0
void CPixelBufferView::OnSaveBitmap()
{
	if(!m_pixelBufferBitmap.IsEmpty())
	{
		Framework::Win32::CFileDialog openFileDialog;
		openFileDialog.m_OFN.lpstrFilter = _T("Windows Bitmap Files (*.bmp)\0*.bmp");
		int result = openFileDialog.SummonSave(m_hWnd);
		if(result == IDOK)
		{
			try
			{
				auto outputStream = Framework::CreateOutputStdStream(std::tstring(openFileDialog.m_OFN.lpstrFile));
				Framework::CBMP::WriteBitmap(m_pixelBufferBitmap, outputStream);
			}
			catch(const std::exception& exception)
			{
				auto message = string_format("Failed to save buffer to file:\r\n\r\n%s", exception.what());
				MessageBoxA(m_hWnd, message.c_str(), nullptr, MB_ICONHAND);
			}
		}
	}
}