Exemple #1
0
LRESULT CMainDlg::OnPrintScreen(WPARAM wParam, LPARAM lParam)
{
	BOOL bAltDown = (BOOL)wParam;

	HWND hWnd = NULL;
	if(bAltDown)
		hWnd = ::GetForegroundWindow();
	else
		hWnd = ::GetDesktopWindow();
	
	// Grab screenshot 
	HBITMAP hScreenshotBmp = GetScreenshot(hWnd, NULL);
	ASSERT(hScreenshotBmp);

	// Create file name
	CString strFile = GetOutputFileName();

	// Create full file path/name
	CString strFilePath = m_strImagePath;
	strFilePath += strFile;

	SaveImageAs(hScreenshotBmp, strFilePath);

	// Clean up dib
	::DeleteObject(hScreenshotBmp);
	
	return 0;
}
Exemple #2
0
void ScreenshotButton::onClick(wxCommandEvent& WXUNUSED(event)) {
   SetBitmapPressed(normal);  //nechci aby na screenshotu vypadal zmacknuty
   Refresh();
   wxBitmap screenshot;
   GetScreenshot(screenshot);
   //screenshot.ClearAlpha();
   SetBitmapPressed(press);
   /**Ulozeni dp souboru**/
   wxFileDialog fileDialog(this, _("Save a screenshot"), wxT(""), wxT("spektrograf.bmp"), wxT("Rastr (*.bmp) | *.bmp|Obrázek PNG (nedoporuèuje se) (*.png) | *.png|JPEG formát (*.jpg) | *.jpeg;*.jpg"), wxFD_SAVE);
   if(fileDialog.ShowModal() == wxID_OK) {
          wxFileName namePath(fileDialog.GetPath());
          int fileType = wxBITMAP_TYPE_BMP;
          if( namePath.GetExt().CmpNoCase(wxT("jpeg")) == 0 ) fileType = wxBITMAP_TYPE_JPEG;
          if( namePath.GetExt().CmpNoCase(wxT("jpg")) == 0 )  fileType = wxBITMAP_TYPE_JPEG;
          if( namePath.GetExt().CmpNoCase(wxT("png")) == 0 )  fileType = wxBITMAP_TYPE_PNG;
		  if( namePath.GetExt().CmpNoCase(wxT("bmp")) == 0 )  fileType = wxBITMAP_TYPE_BMP;
		  wxImage tosave(screenshot.ConvertToImage());
		  if(tosave.HasAlpha())
		    tosave.ClearAlpha();

		  if(wxFileExists(fileDialog.GetPath())) 
		  {
			  wxMessageDialog potvrd(this, _("Soubor existuje! Chcete jej pøepsat?"), _("Soubor existuje"), wxYES_NO|wxNO_DEFAULT|wxICON_WARNING);
			  if(potvrd.ShowModal()==wxID_YES)
				  tosave.SaveFile(fileDialog.GetPath(),(wxBitmapType)fileType);

		  }
		  else 
		    tosave.SaveFile(fileDialog.GetPath(),(wxBitmapType)fileType);
   }
   return;
}
Exemple #3
0
BOOL CMainDlg::ActivateSelectionHook(BOOL bActivate)
{
	// Check if already active
	if(m_bMouseHook == bActivate)
		return TRUE;

	if(bActivate)
	{
		// Get desktop window handle
		HWND hDesktop = ::GetDesktopWindow();
		ASSERT(hDesktop);

		// We just called minimize so refresh desktop
		::InvalidateRect(hDesktop, NULL, TRUE);
		::UpdateWindow(hDesktop);
	
		// Grab screenshot of entire desktop (before ruber band is drawn)
		m_hTmpDraw = GetScreenshot(hDesktop);
		if(!m_hTmpDraw)
			return FALSE;
	
		// Set mouse hook
		m_hMouseHook = ::SetWindowsHookEx(WH_MOUSE_LL, 
			(HOOKPROC)LowLevelMouseProc, GetModuleHandle(NULL), 0);
		if(!m_hMouseHook)
			return FALSE;
		
		// Get desktop DC
		m_pDesktopDC = CDC::FromHandle(::GetDCEx(hDesktop, 0, DCX_WINDOW));
		ASSERT(m_pDesktopDC);
	}
	else
	{
		// Release screen DC
		if(m_pDesktopDC != NULL)
		{
			::ReleaseDC(::GetDesktopWindow(), m_pDesktopDC->GetSafeHdc());
			m_pDesktopDC = NULL;
		}

		// Release hook
		if(m_hMouseHook)
		{
			::UnhookWindowsHookEx(m_hMouseHook);
			m_hMouseHook = NULL;
		}
	}

	m_bMouseHook = bActivate;

	return TRUE;
}
Exemple #4
0
FExecStatus FCameraCommandHandler::GetObjectInstanceMask(const TArray<FString>& Args)
{
	if (Args.Num() <= 2) // The first is camera id, the second is ViewMode
	{
		// Use command dispatcher is more universal
		FExecStatus ExecStatus = CommandDispatcher->Exec(TEXT("vset /viewmode object_mask"));
		if (ExecStatus != FExecStatusType::OK)
		{
			return ExecStatus;
		}

		ExecStatus = GetScreenshot(Args);
		return ExecStatus;
	}
	return FExecStatus::InvalidArgument;
}
Exemple #5
0
LRESULT CMainDlg::OnSelectionComplete(WPARAM wParam, LPARAM lParam)
{
	// Remove mouse hook
	ActivateSelectionHook(FALSE);

	// Grab screenshot 
	HBITMAP hScreenshotBmp = NULL;
	if((m_hHilightWnd) && (::IsWindow(m_hHilightWnd)))
		hScreenshotBmp = GetScreenshot(m_hHilightWnd, NULL);
		
	// Check if we were launched from tray menu
	if(!m_bStayInTray) 
	{
		// Uncheck button
		CButton* pBtn = (CButton*)GetDlgItem(IDC_WIN_SELECT);
		ASSERT(pBtn);
		pBtn->SetCheck(0);

		// Restore self
		ShowWindow(SW_RESTORE);
	}
	m_bStayInTray = FALSE;

	// Do not continue if aquiring screenshot failed
	if(!hScreenshotBmp)
		return -1;
	
	// Create file name
	CString strFile = GetOutputFileName();

	// Create full file path/name
	CString strFilePath = m_strImagePath;
	strFilePath += strFile;

	// Save screenshot as jpeg
	SaveImageAs(hScreenshotBmp, strFilePath);

	// Clean up dib
	::DeleteObject(hScreenshotBmp);

	return 0;
}
Exemple #6
0
void VideoMetadata::toMap(MetadataMap &metadataMap)
{
    if (this == NULL)
        return;

    QString coverfile;
    if (IsHostSet()
        && !GetCoverFile().startsWith("/")
        && !GetCoverFile().isEmpty()
        && !IsDefaultCoverFile(GetCoverFile()))
    {
        coverfile = generate_file_url("Coverart", GetHost(),
                GetCoverFile());
    }
    else
    {
        coverfile = GetCoverFile();
    }

    metadataMap["coverfile"] = coverfile;

    QString screenshotfile;
    if (IsHostSet() && !GetScreenshot().startsWith("/")
        && !GetScreenshot().isEmpty())
    {
        screenshotfile = generate_file_url("Screenshots",
                GetHost(), GetScreenshot());
    }
    else
    {
        screenshotfile = GetScreenshot();
    }

    metadataMap["screenshotfile"] = screenshotfile;

    QString bannerfile;
    if (IsHostSet() && !GetBanner().startsWith("/")
        && !GetBanner().isEmpty())
    {
        bannerfile = generate_file_url("Banners", GetHost(),
                GetBanner());
    }
    else
    {
        bannerfile = GetBanner();
    }

    metadataMap["bannerfile"] = bannerfile;

    QString fanartfile;
    if (IsHostSet() && !GetFanart().startsWith("/")
        && !GetFanart().isEmpty())
    {
        fanartfile = generate_file_url("Fanart", GetHost(),
                GetFanart());
    }
    else
    {
        fanartfile = GetFanart();
    }

    metadataMap["fanartfile"] = fanartfile;

    metadataMap["filename"] = GetFilename();
    metadataMap["title"] = GetTitle();
    metadataMap["subtitle"] = GetSubtitle();
    metadataMap["tagline"] = GetTagline();
    metadataMap["director"] = GetDirector();
    metadataMap["studio"] = GetStudio();
    metadataMap["description"] = GetPlot();
    metadataMap["genres"] = GetDisplayGenres(*this);
    metadataMap["countries"] = GetDisplayCountries(*this);
    metadataMap["cast"] = GetDisplayCast(*this).join(", ");
    metadataMap["rating"] = GetDisplayRating(GetRating());
    metadataMap["length"] = GetDisplayLength(GetLength());
    metadataMap["year"] = GetDisplayYear(GetYear());

    metadataMap["releasedate"] = MythDateToString(GetReleaseDate(), kDateFull);

    metadataMap["userrating"] = GetDisplayUserRating(GetUserRating());
    metadataMap["season"] = GetDisplaySeasonEpisode(GetSeason(), 1);
    metadataMap["episode"] = GetDisplaySeasonEpisode(GetEpisode(), 1);

    if (GetSeason() > 0 || GetEpisode() > 0)
    {
        metadataMap["s##e##"] = QString("s%1e%2").arg(GetDisplaySeasonEpisode
                                             (GetSeason(), 2))
                        .arg(GetDisplaySeasonEpisode(GetEpisode(), 2));
        metadataMap["##x##"] = QString("%1x%2").arg(GetDisplaySeasonEpisode
                                             (GetSeason(), 1))
                        .arg(GetDisplaySeasonEpisode(GetEpisode(), 2));
    }
    else
        metadataMap["s##e##"] = metadataMap["##x##"] = QString();

    metadataMap["trailerstate"] = TrailerToState(GetTrailer());
    metadataMap["userratingstate"] =
            QString::number((int)(GetUserRating()));
    metadataMap["watchedstate"] = WatchedToState(GetWatched());

    metadataMap["videolevel"] = ParentalLevelToState(GetShowLevel());

    metadataMap["insertdate"] = MythDateToString(GetInsertdate(), kDateFull);
    metadataMap["inetref"] = GetInetRef();
    metadataMap["homepage"] = GetHomepage();
    metadataMap["child_id"] = QString::number(GetChildID());
    metadataMap["browseable"] = GetDisplayBrowse(GetBrowse());
    metadataMap["watched"] = GetDisplayWatched(GetWatched());
    metadataMap["processed"] = GetDisplayProcessed(GetProcessed());
    metadataMap["category"] = GetCategory();
}