Allowed saving of screenshots and copying video frames to clipboard without subtitles. This will not work with the avisynth video provider (options will be greyed out).
Originally committed to SVN as r1020.
This commit is contained in:
parent
cfd9065cb4
commit
7da5406572
4 changed files with 51 additions and 13 deletions
|
@ -405,7 +405,7 @@ wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) {
|
|||
|
||||
////////////////////////
|
||||
// Requests a new frame
|
||||
AegiVideoFrame VideoContext::GetFrame(int n) {
|
||||
AegiVideoFrame VideoContext::GetFrame(int n,bool raw) {
|
||||
// Current frame if -1
|
||||
if (n == -1) n = frame_n;
|
||||
|
||||
|
@ -426,7 +426,7 @@ AegiVideoFrame VideoContext::GetFrame(int n) {
|
|||
}
|
||||
|
||||
// Raster subtitles if available/necessary
|
||||
if (subsProvider && subsProvider->CanRaster()) {
|
||||
if (!raw && subsProvider && subsProvider->CanRaster()) {
|
||||
tempFrame.CopyFrom(*srcFrame);
|
||||
subsProvider->DrawSubtitles(tempFrame,VFR_Input.GetTimeAtFrame(n,true,true)/1000.0);
|
||||
return tempFrame;
|
||||
|
@ -547,7 +547,7 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
|
|||
|
||||
/////////////////
|
||||
// Save snapshot
|
||||
void VideoContext::SaveSnapshot() {
|
||||
void VideoContext::SaveSnapshot(bool raw) {
|
||||
// Get folder
|
||||
wxString option = Options.AsText(_("Video Screenshot Path"));
|
||||
wxFileName videoFile(videoName);
|
||||
|
@ -576,7 +576,7 @@ void VideoContext::SaveSnapshot() {
|
|||
}
|
||||
|
||||
// Save
|
||||
GetFrame(frame_n).GetImage().SaveFile(path,wxBITMAP_TYPE_PNG);
|
||||
GetFrame(frame_n,raw).GetImage().SaveFile(path,wxBITMAP_TYPE_PNG);
|
||||
}
|
||||
|
||||
|
||||
|
@ -797,3 +797,10 @@ void VideoContext::SetAspectRatio(int _type, double value) {
|
|||
void VideoContext::SetShader(bool enabled) {
|
||||
OpenGLWrapper::SetShader(enabled ? yv12shader : 0);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Can draw subtitles independently from video?
|
||||
bool VideoContext::HasIndependentSubs() {
|
||||
return subsProvider && subsProvider->CanRaster();
|
||||
}
|
||||
|
|
|
@ -124,8 +124,10 @@ public:
|
|||
void RemoveDisplay(VideoDisplay *display);
|
||||
|
||||
VideoProvider *GetProvider() { return provider; }
|
||||
AegiVideoFrame GetFrame(int n);
|
||||
void SaveSnapshot();
|
||||
AegiVideoFrame GetFrame(int n,bool raw=false);
|
||||
|
||||
bool HasIndependentSubs();
|
||||
void SaveSnapshot(bool raw);
|
||||
|
||||
wxGLContext *GetGLContext(wxGLCanvas *canvas);
|
||||
GLuint GetFrameAsTexture(int n);
|
||||
|
|
|
@ -68,9 +68,11 @@
|
|||
///////
|
||||
// IDs
|
||||
enum {
|
||||
VIDEO_MENU_COPY_TO_CLIPBOARD = 1230,
|
||||
VIDEO_MENU_COPY_COORDS,
|
||||
VIDEO_MENU_COPY_COORDS = 1230,
|
||||
VIDEO_MENU_COPY_TO_CLIPBOARD,
|
||||
VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,
|
||||
VIDEO_MENU_SAVE_SNAPSHOT,
|
||||
VIDEO_MENU_SAVE_SNAPSHOT_RAW
|
||||
};
|
||||
|
||||
|
||||
|
@ -84,9 +86,11 @@ BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
|
|||
EVT_SIZE(VideoDisplay::OnSizeEvent)
|
||||
EVT_ERASE_BACKGROUND(VideoDisplay::OnEraseBackground)
|
||||
|
||||
EVT_MENU(VIDEO_MENU_COPY_COORDS,VideoDisplay::OnCopyCoords)
|
||||
EVT_MENU(VIDEO_MENU_COPY_TO_CLIPBOARD,VideoDisplay::OnCopyToClipboard)
|
||||
EVT_MENU(VIDEO_MENU_SAVE_SNAPSHOT,VideoDisplay::OnSaveSnapshot)
|
||||
EVT_MENU(VIDEO_MENU_COPY_COORDS,VideoDisplay::OnCopyCoords)
|
||||
EVT_MENU(VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,VideoDisplay::OnCopyToClipboardRaw)
|
||||
EVT_MENU(VIDEO_MENU_SAVE_SNAPSHOT_RAW,VideoDisplay::OnSaveSnapshotRaw)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -353,6 +357,11 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
|
|||
wxMenu menu;
|
||||
menu.Append(VIDEO_MENU_SAVE_SNAPSHOT,_("Save PNG snapshot"));
|
||||
menu.Append(VIDEO_MENU_COPY_TO_CLIPBOARD,_("Copy image to Clipboard"));
|
||||
menu.AppendSeparator();
|
||||
bool canDoRaw = VideoContext::Get()->HasIndependentSubs();
|
||||
menu.Append(VIDEO_MENU_SAVE_SNAPSHOT_RAW,_("Save PNG snapshot (no subtitles)"))->Enable(canDoRaw);
|
||||
menu.Append(VIDEO_MENU_COPY_TO_CLIPBOARD_RAW,_("Copy image to Clipboard (no subtitles)"))->Enable(canDoRaw);
|
||||
menu.AppendSeparator();
|
||||
menu.Append(VIDEO_MENU_COPY_COORDS,_("Copy coordinates to Clipboard"));
|
||||
PopupMenu(&menu);
|
||||
return;
|
||||
|
@ -491,10 +500,27 @@ void VideoDisplay::OnCopyToClipboard(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// Copy to clipboard (raw)
|
||||
void VideoDisplay::OnCopyToClipboardRaw(wxCommandEvent &event) {
|
||||
if (wxTheClipboard->Open()) {
|
||||
wxTheClipboard->SetData(new wxBitmapDataObject(wxBitmap(VideoContext::Get()->GetFrame(-1,true).GetImage(),24)));
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////
|
||||
// Save snapshot
|
||||
void VideoDisplay::OnSaveSnapshot(wxCommandEvent &event) {
|
||||
VideoContext::Get()->SaveSnapshot();
|
||||
VideoContext::Get()->SaveSnapshot(false);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Save snapshot (raw)
|
||||
void VideoDisplay::OnSaveSnapshotRaw(wxCommandEvent &event) {
|
||||
VideoContext::Get()->SaveSnapshot(true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -76,12 +76,15 @@ private:
|
|||
void OnKey(wxKeyEvent &event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnMouseLeave(wxMouseEvent& event);
|
||||
void OnCopyToClipboard(wxCommandEvent &event);
|
||||
void OnSaveSnapshot(wxCommandEvent &event);
|
||||
void OnCopyCoords(wxCommandEvent &event);
|
||||
void OnEraseBackground(wxEraseEvent &event) {}
|
||||
void OnSizeEvent(wxSizeEvent &event);
|
||||
|
||||
void OnCopyCoords(wxCommandEvent &event);
|
||||
void OnCopyToClipboard(wxCommandEvent &event);
|
||||
void OnSaveSnapshot(wxCommandEvent &event);
|
||||
void OnCopyToClipboardRaw(wxCommandEvent &event);
|
||||
void OnSaveSnapshotRaw(wxCommandEvent &event);
|
||||
|
||||
public:
|
||||
VideoDisplayVisual *visual;
|
||||
VideoDisplayFexTracker *tracker;
|
||||
|
|
Loading…
Reference in a new issue