From db0cc24ae3bf7f768ba1fd50ded76da4f3715ca4 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Thu, 20 Mar 2008 21:48:47 +0000 Subject: [PATCH] Originally committed to SVN as r2083. --- aegisub/charset_detect.cpp | 1 + aegisub/subtitle_format_dvd.cpp | 45 +++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/aegisub/charset_detect.cpp b/aegisub/charset_detect.cpp index 79e0cda51..e2d8b136e 100644 --- a/aegisub/charset_detect.cpp +++ b/aegisub/charset_detect.cpp @@ -37,6 +37,7 @@ /////////// // Headers #ifdef WITH_UNIVCHARDET +#include #include "charset_detect.h" #include "text_file_reader.h" #include "../universalchardet/nsCharSetProber.h" diff --git a/aegisub/subtitle_format_dvd.cpp b/aegisub/subtitle_format_dvd.cpp index 097165318..e2a0e7347 100644 --- a/aegisub/subtitle_format_dvd.cpp +++ b/aegisub/subtitle_format_dvd.cpp @@ -41,11 +41,17 @@ #include "subtitles_provider_manager.h" #include "ass_dialogue.h" #include "ass_file.h" +#undef _OPENMP #ifdef _OPENMP #include #endif #include +//#undef MAX_PATH +//#include +// +//#pragma comment(lib, "tessdll.lib") + /////////////// // Format name @@ -96,9 +102,10 @@ void DVDSubtitleFormat::GetSubPictureList(std::vector &pics) { SubtitlesProvider *provider = NULL; provider = SubtitlesProviderFactoryManager::GetProvider(); provider->LoadSubtitles(GetAssFile()); + //TessDllAPI tess; // Write lines - int i; + int i=0; #ifdef _OPENMP #pragma omp parallel for shared(diags,pics,provider) private(i) #endif @@ -117,8 +124,36 @@ void DVDSubtitleFormat::GetSubPictureList(std::vector &pics) { provider->DrawSubtitles(dst,time); } wxImage img = dst.GetImage(); + img.SaveFile(_T("test.bmp")); dst.Clear(); + // Tesseract test + /* + tess.BeginPageUpright(img.GetWidth(),img.GetHeight(),img.GetData(),24); + ETEXT_DESC *output = tess.Recognize_all_Words(); + wxString blah; + int j; + for (int cur = 0; cur < output->count; cur = j) { + const EANYCODE_CHAR* ch = &output->text[cur]; + unsigned char unistr[8]; + + for (int b = 0; b < ch->blanks; ++b) blah += _T(" "); + + for (j = cur; j < output->count; j++) { + const EANYCODE_CHAR* unich = &output->text[j]; + + if (ch->left != unich->left || ch->right != unich->right || + ch->top != unich->top || ch->bottom != unich->bottom) + break; + unistr[j - cur] = static_cast(unich->char_code); + } + unistr[j - cur] = '\0'; + blah += wxString((char*)unistr,wxConvUTF8); + if (ch->formatting & 64) blah += _T("\n"); + } + wxLogMessage(blah); + */ + // Perform colour reduction on image unsigned char r,g,b; unsigned char *data = img.GetData(); @@ -351,7 +386,7 @@ void DVDSubtitleFormat::WriteFile(wxString filename,wxString encoding) { pos += fp.Write(&pics[i].data[1][0],pics[i].data[1].size()); // Control group data - size_t comm2add = packetLen - 4; + size_t comm2add = packetLen - 6; unsigned char comm2_b1 = (comm2add & 0xFF00) >> 8; unsigned char comm2_b2 = comm2add & 0xFF; unsigned char pix0_b1 = (line0pos & 0xFF00) >> 8; @@ -376,11 +411,11 @@ void DVDSubtitleFormat::WriteFile(wxString filename,wxString encoding) { unsigned char control[] = { 0x00, 0x00, // Delay comm2_b1, comm2_b2, // Next command - 0x03, 0x01, 0x23, // Set colours - 0x04, 0x0F, 0xFF, // Alpha blend + 0x01, // Start display + 0x03, 0x82, 0x30, // Set colours + 0x04, 0xFF, 0xF0, // Alpha blend 0x05, dispx_b1, dispx_b2, dispx_b3, dispy_b1, dispy_b2, dispy_b3, // Display area 0x06, pix0_b1, pix0_b2, pix1_b1, pix1_b2, // Pixel pointers - 0x01, // Start display 0xFF, // End block 1 delay_b1, delay_b2, // Delay comm2_b1, comm2_b2, // This command