diff --git a/core/subtitle_format_prs.cpp b/core/subtitle_format_prs.cpp index 4fe22192e..683f2bcc2 100644 --- a/core/subtitle_format_prs.cpp +++ b/core/subtitle_format_prs.cpp @@ -106,26 +106,32 @@ void PRSSubtitleFormat::WriteFile(wxString filename,wxString encoding) { // Get range std::vector frames = GetFrameRanges(); + int totalFrames = frames.size(); + int toDraw = 0; + for (int i=0;iShow(); - progress->SetProgress(0,totalFrames); + progress->SetProgress(0,toDraw); // Render all frames that were detected to contain subtitles + int drawn = 0; for (int framen=0;framenSetProgress(framen,totalFrames); + progress->SetProgress(drawn,toDraw); progress->SetText(wxString::Format(_T("Writing PRS file. Line: %i/%i"),framen,totalFrames)); + drawn++; // Read the frame image PVideoFrame frame1 = clip1->GetFrame(framen,env1); @@ -139,8 +145,21 @@ void PRSSubtitleFormat::WriteFile(wxString filename,wxString encoding) { wxImage bmp = CalculateAlpha(frame1->GetReadPtr(),frame2->GetReadPtr(),frame1->GetRowSize(),frame1->GetHeight(),frame1->GetPitch(),&x,&y,&maxalpha); if (!bmp.Ok()) continue; - // Add image to file - InsertFrame(file,framen,frames,bmp,x,y,maxalpha); + // Get the list of rectangles + std::vector rects; + GetSubPictureRectangles(bmp,rects); + + // Add each sub-image to file + int nrects = rects.size(); + for (int i=0;i & } +/////////////////////////////////// +// Get rectangles of useful glyphs +void PRSSubtitleFormat::GetSubPictureRectangles(wxImage image,std::vector &rects) { + rects.push_back(wxRect(0,0,image.GetWidth(),image.GetHeight())); +} + + //////////////////// // Get frame ranges std::vector PRSSubtitleFormat::GetFrameRanges() { diff --git a/core/subtitle_format_prs.h b/core/subtitle_format_prs.h index b80a52517..377d95be4 100644 --- a/core/subtitle_format_prs.h +++ b/core/subtitle_format_prs.h @@ -61,6 +61,7 @@ private: void InsertFrame(PRSFile &file,int &framen,std::vector &frames,wxImage &bmp,int x,int y,int maxalpha); wxImage SubImageWithAlpha(wxImage src,const wxRect &area); wxImage CalculateAlpha(const unsigned char* frame1, const unsigned char* frame2, int w, int h, int pitch, int *x=NULL, int *y=NULL, int *maxalpha=NULL); + void GetSubPictureRectangles(wxImage image,std::vector &rects); std::vector GetFrameRanges(); public: