cv::Mat resizeCharacter(OfflineGridUBytePicture *character) { int srcwidth = character->width; int srcheight = character->height; cv::Mat img=cv::Mat::zeros(srcheight,srcwidth,CV_8U); for (int m = 0; m < srcheight; m++) { for (int n = 0; n < srcwidth; n++) { img.at<uchar>(m,n) = character->bitmap[m * srcwidth + n]; } } if(srcheight>srcwidth) { double ratio = (double) characterHeight / srcheight; int width = min(int(std::floor(ratio * srcwidth)), characterWidth); cv::Mat img_resize=cv::Mat::zeros(characterHeight,width,CV_8UC1); resize(img, img_resize, cvSize(width,characterHeight),0,0,CV_INTER_LINEAR); cv::Mat maskImg=maskCharacter(img_resize, width, true); img.release(); img_resize.release(); return maskImg; } else { double ratio = (double) characterWidth / srcwidth; int height = min(int(std::floor(ratio * srcheight)), characterHeight); cv::Mat img_resize=cv::Mat::zeros(characterWidth,height,CV_8UC1); resize(img, img_resize, cvSize(characterWidth,height),0,0,CV_INTER_LINEAR); cv::Mat maskImg = maskCharacter(img_resize, height, false); img.release(); img_resize.release(); return maskImg; } }
void CodeGenerator::processRootState() { if (readAfterEOF && in!=&cin){ in->seekg (0, ios::end); // output the last few lines or the complete file if not too big if (in->tellg()>51200) { in->seekg (-512, ios::end); // output complete lines, ignore first line fragment in->ignore(512, '\n'); } else { in->seekg (0, ios::beg); // output complete file } } string line; size_t i=0; bool tagOpen=false; while (true) { if (!getline(*in, line)) { // imitate tail bahaviour, continue to read after EOF if (readAfterEOF) { out->flush(); in->clear(); #ifdef WIN32 Sleep(250); #else sleep(1); #endif } else { //todo hier position merken, in der gui periodisch den dateizeiger auf diesen wert setzen und den neuen code einlesen break; } } else { i=0; size_t seqEnd=string::npos; while (i <line.length() ) { if (line[i]==0x1b) { // fix grep --colour .[K (1b 5b 4b) sequences if (line.length()>i+2 && line[i+2]==0x4b){ seqEnd=i+2; } else { seqEnd=line.find_first_of('m', i+1); //TODO vor ; das hier anfangen xterm: ^[]0;~^G^M^M // http://www.mit.edu/afs/athena/system/x11r4/src/mit/clients/xterm/ctlseq2.txt if (seqEnd==string::npos) { if (line[i+1]==']') seqEnd=line.find(0x07, i+1); } if (seqEnd==string::npos) seqEnd=line.find(';', i+1); if (seqEnd==string::npos) seqEnd=line.find('h', i+1); if (!ignoreFormatting && seqEnd!=string::npos) { if (!elementStyle.isReset()){ *out <<getCloseTag(); tagOpen=false; } parseSequence(line, i, seqEnd); if (!elementStyle.isReset()) { *out <<getOpenTag(); tagOpen=true; } } } i= 1+ ((seqEnd!=string::npos)?seqEnd:i); } else { *out << maskCharacter(line[i]); ++i; } } *out << newLineTag; } } if (tagOpen){ *out <<getCloseTag(); } out->flush(); }