//Фильтр "Гамма-коррекция" //Параметры: // hDC DC назначения // lW Ширина DC // lH Высота DC // dblGamma Степень гаммы. Допустимые значения: от 0.1 до 1.9 // pRC Указатель на структуру RECT, определяющую область изображения для изменения // hWndCallback Окно уведомлений о ходе работы (опционально) //Возвращаемое значение: TRUE в случае успеха, FALSE в случае ошибки BOOL GammaCorrection(HDC hDC, ULONG lW, ULONG lH, double dblGamma, LPRECT pRC, HWND hWndCallback) { LPBYTE pPixels = NULL; ULONG lBytesCnt = 0; LPBITMAPINFO pBMI = NULL; ULONG lColor, lR, lG, lB; LONG i, j; volatile ONPROGRESSPARAMS ONPP = {}; if (!GetImagePixels(hDC, lW, lH, &pPixels, &lBytesCnt, &pBMI)) { if (pPixels) delete[] pPixels; if (pBMI) delete pBMI; return FALSE; } for (j = pRC->top; j < pRC->bottom; j++) { for (i = pRC->left; i < pRC->right; i++) { lColor = GetPixel(pPixels, pBMI, i, j); lR = R_BGRA(lColor); lG = G_BGRA(lColor); lB = B_BGRA(lColor); lR = (ULONG)CheckBounds((LONG)((255.0 * pow((double)lR / 255.0, 1.0 / dblGamma)) + 0.5), (LONG)0, (LONG)255); lG = (ULONG)CheckBounds((LONG)((255.0 * pow((double)lG / 255.0, 1.0 / dblGamma)) + 0.5), (LONG)0, (LONG)255); lB = (ULONG)CheckBounds((LONG)((255.0 * pow((double)lB / 255.0, 1.0 / dblGamma)) + 0.5), (LONG)0, (LONG)255); SetPixel(pPixels, pBMI, i, j, BGR(lB, lG, lR)); } if (hWndCallback) { ONPP.dwPercents = (DWORD)(((double)j / (double)pRC->bottom) * 100); SendMessage(hWndCallback, WM_GRAPHICSEVENT, MAKEWPARAM(EVENT_ON_PROGRESS, 0), (LPARAM)&ONPP); } } SetImagePixels(hDC, lW, lH, pPixels, pBMI); delete[] pPixels; delete pBMI; return TRUE; }
const HRESULT CPVI_Canvas::Init(const char* name/*=0*/) { char temp[MAX_PATH]; _snprintf_s(temp, MAX_PATH, _TRUNCATE, "%s.blind", _strconf); _bHasBackground = _config->getBool(temp); IGlyph* g = 0; if (_bHasBackground) { _blind = new CBlind(_name, BGR(0, 0, 0), 0.5); g = AppendChild(_gt.begin(), _blind); } try { //_my_disp; char temp[MAX_PATH]; _snprintf_s(temp, MAX_PATH, "%s.containers", this->_strconf); strcpy_s(_my_cont, MAX_PATH, _config->getString(temp).c_str()); _snprintf_s(temp, MAX_PATH, _TRUNCATE, "%s.rect-percentage", _strconf); _config->getTripleFloat(_tt_layout, temp); _snprintf_s(temp, MAX_PATH, _TRUNCATE, "%s.margin", _strconf); _config->getRect(_margin, temp); _snprintf_s(temp, MAX_PATH, _TRUNCATE, "%s.chart-interval", _strconf); _chart_interval = _config->getInt(temp); _prc_chart = new CPriceTickChart("price-chart"); _snprintf_s(temp, MAX_PATH, "%s.price-chart", _strconf); _prc_chart->setConfig(_config, temp); if (!g) g = AppendChild(_gt.begin(), _prc_chart); else g = InsertNext(g->GetGlyphTreeIter(), _prc_chart); _prc_chart->AddGraphs(); _vol_chart = new CVolumeTickChart("volume-chart"); _snprintf_s(temp, MAX_PATH, "%s.volume-chart", _strconf); _vol_chart->setConfig(_config, temp); g = InsertNext(g->GetGlyphTreeIter(), _vol_chart); _vol_chart->AddGraphs(); _itr_chart = new CInterestTickChart("interest-chart"); _snprintf_s(temp, MAX_PATH, "%s.interest-chart", _strconf); _itr_chart->setConfig(_config, temp); g = InsertNext(g->GetGlyphTreeIter(), _itr_chart); _itr_chart->AddGraphs(); } catch(...) { return (-1); } return S_OK; }
int curses_start_color(void) { colorpairs = new pairs[100]; windowsPalette = new RGBQUAD[16]; //Load the console colors from colors.json std::ifstream colorfile(FILENAMES["colors"].c_str(), std::ifstream::in | std::ifstream::binary); try{ JsonIn jsin(colorfile); char ch; // Manually load the colordef object because the json handler isn't loaded yet. jsin.eat_whitespace(); ch = jsin.peek(); if( ch == '[' ) { jsin.start_array(); // find type and dispatch each object until array close while (!jsin.end_array()) { jsin.eat_whitespace(); char ch = jsin.peek(); if (ch != '{') { std::stringstream err; err << jsin.line_number() << ": "; err << "expected array of objects but found '"; err << ch << "', not '{'"; throw err.str(); } JsonObject jo = jsin.get_object(); load_colors(jo); jo.finish(); } } else { // not an array? std::stringstream err; err << jsin.line_number() << ": "; err << "expected object or array, but found '" << ch << "'"; throw err.str(); } } catch(std::string e){ throw FILENAMES["colors"] + ": " + e; } if(consolecolors.empty())return SetDIBColorTable(backbuffer, 0, 16, windowsPalette); windowsPalette[0] = BGR(ccolor("BLACK")); windowsPalette[1] = BGR(ccolor("RED")); windowsPalette[2] = BGR(ccolor("GREEN")); windowsPalette[3] = BGR(ccolor("BROWN")); windowsPalette[4] = BGR(ccolor("BLUE")); windowsPalette[5] = BGR(ccolor("MAGENTA")); windowsPalette[6] = BGR(ccolor("CYAN")); windowsPalette[7] = BGR(ccolor("GRAY")); windowsPalette[8] = BGR(ccolor("DGRAY")); windowsPalette[9] = BGR(ccolor("LRED")); windowsPalette[10] = BGR(ccolor("LGREEN")); windowsPalette[11] = BGR(ccolor("YELLOW")); windowsPalette[12] = BGR(ccolor("LBLUE")); windowsPalette[13] = BGR(ccolor("LMAGENTA")); windowsPalette[14] = BGR(ccolor("LCYAN")); windowsPalette[15] = BGR(ccolor("WHITE")); return SetDIBColorTable(backbuffer, 0, 16, windowsPalette); }
int curses_start_color(void) { colorpairs=new pairs[50]; windowsPalette[0]= BGR(0,0,0); // Black windowsPalette[1]= BGR(0, 0, 255); // Red windowsPalette[2]= BGR(0,110,0); // Green windowsPalette[3]= BGR(23,51,92); // Brown??? windowsPalette[4]= BGR(200, 0, 0); // Blue windowsPalette[5]= BGR(98, 58, 139); // Purple windowsPalette[6]= BGR(180, 150, 0); // Cyan windowsPalette[7]= BGR(150, 150, 150);// Gray windowsPalette[8]= BGR(99, 99, 99);// Dark Gray windowsPalette[9]= BGR(150, 150, 255); // Light Red/Salmon? windowsPalette[10]= BGR(0, 255, 0); // Bright Green windowsPalette[11]= BGR(0, 255, 255); // Yellow windowsPalette[12]= BGR(255, 100, 100); // Light Blue windowsPalette[13]= BGR(240, 0, 255); // Pink windowsPalette[14]= BGR(255, 240, 0); // Light Cyan? windowsPalette[15]= BGR(255, 255, 255); //White //SDL_SetColors(screen,windowsPalette,0,256); return 0; }
static bool svg_redraw_internal(struct content *c, int x, int y, int width, int height, const struct rect *clip, const struct redraw_context *ctx, float scale, colour background_colour) { svg_content *svg = (svg_content *) c; float transform[6]; struct svgtiny_diagram *diagram = svg->diagram; bool ok; int px, py; unsigned int i; plot_font_style_t fstyle = *plot_style_font; assert(diagram); transform[0] = (float) width / (float) c->width; transform[1] = 0; transform[2] = 0; transform[3] = (float) height / (float) c->height; transform[4] = x; transform[5] = y; #define BGR(c) ((c) == svgtiny_TRANSPARENT ? NS_TRANSPARENT : \ ((svgtiny_RED((c))) | \ (svgtiny_GREEN((c)) << 8) | \ (svgtiny_BLUE((c)) << 16))) for (i = 0; i != diagram->shape_count; i++) { if (diagram->shape[i].path) { ok = ctx->plot->path(diagram->shape[i].path, diagram->shape[i].path_length, BGR(diagram->shape[i].fill), diagram->shape[i].stroke_width, BGR(diagram->shape[i].stroke), transform); if (!ok) return false; } else if (diagram->shape[i].text) { px = transform[0] * diagram->shape[i].text_x + transform[2] * diagram->shape[i].text_y + transform[4]; py = transform[1] * diagram->shape[i].text_x + transform[3] * diagram->shape[i].text_y + transform[5]; fstyle.background = 0xffffff; fstyle.foreground = 0x000000; fstyle.size = (8 * FONT_SIZE_SCALE) * scale; ok = ctx->plot->text(px, py, diagram->shape[i].text, strlen(diagram->shape[i].text), &fstyle); if (!ok) return false; } } #undef BGR return true; }
/*input: LAB - lab(l,alpha,beta)signals output:RGB - RGB signals */ cv::Mat Normalization::lab2BGR(cv::Mat LAB) { /*from lab to LMS */ //Matrix1 = [1 1 1; 1 1 -1; 1 -2 0] * diag([sqrt(3)/3 sqrt(6)/6 sqrt(2)/2]); float auxData[9] = {1, 1, 1, 1, 1, -1, 1, -2, 0}; cv::Mat Matrix1 = cv::Mat(3, 3, CV_32FC1, &auxData); cv::Mat diag = cv::Mat(3,3,CV_32FC1, 0.0); diag.at<float>(0,0)= 1/sqrtf(3.0); diag.at<float>(1,1)= 1/sqrtf(6.0); diag.at<float>(2,2)= 1/sqrtf(2.0); Matrix1 *=diag; //log_LMS = [Matrix1 * LAB']'; float m11 = Matrix1.at<float>(0,0), m12 = Matrix1.at<float>(0,1), m13 = Matrix1.at<float>(0,2), m21 = Matrix1.at<float>(1,0), m22 = Matrix1.at<float>(1,1), m23 = Matrix1.at<float>(1,2), m31 = Matrix1.at<float>(2,0), m32 = Matrix1.at<float>(2,1), m33 = Matrix1.at<float>(2,2); // // Print Matrix1 // for (int i=0; i<Matrix1.rows; i++){ // // get pointer to beginning of each line // std::cout << Matrix1.ptr<float>(i)[0] <<", " << Matrix1.ptr<float>(i)[1] <<", "<< Matrix1.ptr<float>(i)[2] << std::endl; // // } cv::Mat log_LMS(LAB.size(), CV_32FC3); for (int i=0; i<LAB.rows; i++){ // get pointer to beginning of each line float *LAB_ptr = LAB.ptr<float>(i); float *log_LMS_ptr = log_LMS.ptr<float>(i); for (int j=0; j<LAB.cols; j++){ float l = LAB_ptr[j*3]; float a = LAB_ptr[j*3+1]; float b = LAB_ptr[j*3+2]; log_LMS_ptr[j*3] = l * m11 + a * m12 + b * m13; log_LMS_ptr[j*3+1] = l * m21 + a * m22 + b * m23; log_LMS_ptr[j*3+2] = l * m31 + a * m32 + b * m33; // if(i==0 && j == 0){ // std::cout << "l: "<< l <<" a:"<<a << " b:"<<b<<std::endl; // std::cout << "lab2BGR: log_LMS(0,0): "<< log_LMS_ptr[j*3] <<" (0,1):"<< log_LMS_ptr[j*3+1] <<" (0,2):"<< log_LMS_ptr[j*3+2] << std::endl; // } } } /* % conver back from log space to linear space LMS = 10.^log_LMS; */ cv::Mat LMS(LAB.size(), CV_32FC3); for (int i=0; i<LMS.rows; i++){ // get pointer to beginning of each line float *LMS_ptr = LMS.ptr<float>(i); float *log_LMS_ptr = log_LMS.ptr<float>(i); for (int j=0; j<LMS.cols; j++){ LMS_ptr[j*3] = pow(10.0f, log_LMS_ptr[j*3]); LMS_ptr[j*3+1] = pow(10.0f, log_LMS_ptr[j*3+1]); LMS_ptr[j*3+2] = pow(10.0f, log_LMS_ptr[j*3+2]); // if(i==0 && j <2 ){ // std::cout << "pow: " << pow(10.0f, log_LMS_ptr[j*3+2]) << std::endl; // std::cout << "lab2BGR: log_LMS(0,0): "<< log_LMS_ptr[j*3] <<" (0,1):"<< log_LMS_ptr[j*3+1] <<" (0,2):"<< log_LMS_ptr[j*3+2] << std::endl; // std::cout << "lab2BGR: LMS(0,0): "<< LMS_ptr[j*3] <<" (0,1):"<< LMS_ptr[j*3+1] <<" (0,2):"<< LMS_ptr[j*3+2] << std::endl; // } } } /* LMS(find(LMS==-Inf)) = 0; LMS(isnan(LMS)) = 0;*/ for (int i=0; i<LMS.rows; i++){ // get pointer to beginning of each line float *LMS_ptr = LMS.ptr<float>(i); for (int j=0; j<LMS.cols; j++){ for(int c = 0; c < LMS.channels(); c++){ float x = LMS_ptr[j*3+c]; if(!(x<= DBL_MAX && x >= -DBL_MAX)){ LMS_ptr[j*3+c] = 0.0; } } } } /*% from linear LMS to RGB Matrix2 = [4.4687 -3.5887 0.1196;-1.2197 2.3831 -0.1626;0.0585 -0.2611 1.2057]; RGB = [Matrix2 * LMS']';*/ // OpenCV stores RGB as BGR, so we have the channels inverted as compared to Matlab cv::Mat BGRF(LMS.size(), LMS.type()); float Matrix2[9] = {4.4687f, -3.5887f, 0.1196f, -1.2197f, 2.3831f, -0.1626f, 0.0585f, -0.2611f, 1.2057f}; m11 = Matrix2[0], m12 = Matrix2[1], m13 = Matrix2[2], m21 = Matrix2[3], m22 = Matrix2[4], m23 = Matrix2[5], m31 = Matrix2[6], m32 = Matrix2[7], m33 = Matrix2[8]; for (int i=0; i<LMS.rows; i++){ // get pointer to beginning of each line float *LMS_ptr = LMS.ptr<float>(i); float *BGRF_ptr = BGRF.ptr<float>(i); for (int j=0; j<LMS.cols; j++){ float l = LMS_ptr[3*j]; float m = LMS_ptr[3*j+1]; float s = LMS_ptr[3*j+2]; float b = l*m31 + m*m32 + s *m33; float g = l*m21 + m*m22 + s *m23; float r = l*m11 + m*m12 + s *m13; BGRF_ptr[3*j] = b; BGRF_ptr[3*j+1] = g; BGRF_ptr[3*j+2] = r; // if(i==0 && j < 2){ // std::cout << "lab2BGR: BGR(0,0): "<< BGRF_ptr[j*3] <<" (0,1):"<< BGRF_ptr[j*3+1] <<" (0,2):"<< BGRF_ptr[j*3+2] << std::endl; // } } } // ColorNormI = reshape(uint8(new_im*255), r,c,d); cv::Mat BGR(LMS.size(), CV_8UC3); for(int i = 0; i < BGR.rows; i++){ float* BGRF_ptr = BGRF.ptr<float>(i); unsigned char* BGR_ptr = BGR.ptr<unsigned char>(i); for(int j = 0; j < BGR.cols; j++){ for(int c=0; c< BGR.channels();c++){ // *255 float bgrfScaled = BGRF_ptr[j*3+c] *255.0; // uint8 if(bgrfScaled < 0.0) bgrfScaled = 0.0; if(bgrfScaled > 255.0) bgrfScaled = 255.0; BGR_ptr[j*3+c] = (unsigned char)Normalization::rndint(bgrfScaled); } } } return BGR; }
int start_color(void) { colorpairs=new pairs[50]; windowsPalette=new RGBQUAD[16]; //Colors in the struct are BGR!! not RGB!! windowsPalette[0]= BGR(0,0,0); windowsPalette[1]= BGR(0, 0, 196); windowsPalette[2]= BGR(0,196,0); windowsPalette[3]= BGR(30,180,196); windowsPalette[4]= BGR(196, 0, 0); windowsPalette[5]= BGR(180, 0, 196); windowsPalette[6]= BGR(200, 170, 0); windowsPalette[7]= BGR(196, 196, 196); windowsPalette[8]= BGR(96, 96, 96); windowsPalette[9]= BGR(64, 64, 255); windowsPalette[10]= BGR(0, 240, 0); windowsPalette[11]= BGR(0, 255, 255); windowsPalette[12]= BGR(255, 20, 20); windowsPalette[13]= BGR(240, 0, 255); windowsPalette[14]= BGR(255, 240, 0); windowsPalette[15]= BGR(255, 255, 255); return SetDIBColorTable(backbuffer, 0, 16, windowsPalette); };
int start_color(void) { colorpairs=new pairs[50]; windowsPalette=new RGBQUAD[16]; //Colors in the struct are BGR!! not RGB!! windowsPalette[0]= BGR(0,0,0); // Black windowsPalette[1]= BGR(0, 0, 255); // Red windowsPalette[2]= BGR(0,100,0); // Green windowsPalette[3]= BGR(23,51,92); // Brown??? windowsPalette[4]= BGR(150, 0, 0); // Blue windowsPalette[5]= BGR(98, 58, 139); // Purple windowsPalette[6]= BGR(180, 150, 0); // Cyan windowsPalette[7]= BGR(196, 196, 196);// Gray windowsPalette[8]= BGR(77, 77, 77);// Dark Gray windowsPalette[9]= BGR(150, 150, 255); // Light Red/Salmon? windowsPalette[10]= BGR(0, 255, 0); // Bright Green windowsPalette[11]= BGR(0, 255, 255); // Yellow windowsPalette[12]= BGR(255, 100, 100); // Light Blue windowsPalette[13]= BGR(240, 0, 255); // Pink windowsPalette[14]= BGR(255, 240, 0); // Light Cyan? windowsPalette[15]= BGR(255, 255, 255); return SetDIBColorTable(backbuffer, 0, 16, windowsPalette); };
int curses_start_color(void) { colorpairs = new pairs[100]; windowsPalette = new RGBQUAD[16]; windowsPalette[0] = BGR(0,0,0); // Black windowsPalette[1] = BGR(0, 0, 255); // Red windowsPalette[2] = BGR(0,110,0); // Green windowsPalette[3] = BGR(23,51,92); // Brown??? windowsPalette[4] = BGR(200, 0, 0); // Blue windowsPalette[5] = BGR(98, 58, 139); // Purple windowsPalette[6] = BGR(180, 150, 0); // Cyan windowsPalette[7] = BGR(150, 150, 150); // Gray windowsPalette[8] = BGR(99, 99, 99); // Dark Gray windowsPalette[9] = BGR(150, 150, 255); // Light Red/Salmon? windowsPalette[10] = BGR(0, 255, 0); // Bright Green windowsPalette[11] = BGR(0, 255, 255); // Yellow windowsPalette[12] = BGR(255, 100, 100); // Light Blue windowsPalette[13] = BGR(240, 0, 255); // Pink windowsPalette[14] = BGR(255, 240, 0); // Light Cyan? windowsPalette[15] = BGR(255, 255, 255); //White return SetDIBColorTable(backbuffer, 0, 16, windowsPalette); }
const HRESULT CEuclidCanvas::Init(const char* name/* = 0*/) { IGlyph* g = 0; if (_bHasBackground) { _blind = new CBlind(_name, BGR(0, 0, 0), 0.8); g = AppendChild(_gt.begin(), _blind); } try { //_my_disp; char temp[MAX_PATH]; _snprintf_s(temp, MAX_PATH, "%s.containers", this->_strconf); strcpy_s(_my_cont, MAX_PATH, _config->getString(temp).c_str()); _prc_chart = new CPriceTickChart("price-chart"); _snprintf_s(temp, MAX_PATH, "%s.price-chart", _strconf); _prc_chart->setConfig(_config, temp); if (!g) g = AppendChild(_gt.begin(), _prc_chart); else g = InsertNext(g->GetGlyphTreeIter(), _prc_chart); _prc_chart->AddGraphs(); _approx_short_lo = new CDataLineGraph("rt-appx_short_lo", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _approx_short_lo->setWorld(_prc_chart->getCoordWorld()); _approx_short_lo->SetLineColor(BGR(255, 0, 0), 1.0f); _approx_short_lo->SetStrokeWidth(.02f); _approx_short_lo->GetGraphData()->SetSize(1024); g = InsertNext(g->GetGlyphTreeIter(), _approx_short_lo); _approx_short_he = new CDataLineGraph("rt-appx_short_he", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _approx_short_he->setWorld(_prc_chart->getCoordWorld()); _approx_short_he->SetLineColor(BGR(0, 255, 0), 1.0f); _approx_short_he->SetStrokeWidth(.02f); _approx_short_he->GetGraphData()->SetSize(1024); g = InsertNext(g->GetGlyphTreeIter(), _approx_short_he); _approx_long_lo = new CDataLineGraph("rt-appx_long_lo", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _approx_long_lo->setWorld(_prc_chart->getCoordWorld()); _approx_long_lo->SetLineColor(BGR(255, 0, 0), 1.0f); _approx_long_lo->SetStrokeWidth(.1f); _approx_long_lo->GetGraphData()->SetSize(1024); g = InsertNext(g->GetGlyphTreeIter(), _approx_long_lo); _approx_long_he = new CDataLineGraph("rt-appx_long_he", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _approx_long_he->setWorld(_prc_chart->getCoordWorld()); _approx_long_he->SetLineColor(BGR(0, 255, 0), 1.0f); _approx_long_he->SetStrokeWidth(.1f); _approx_long_he->GetGraphData()->SetSize(1024); g = InsertNext(g->GetGlyphTreeIter(), _approx_long_he); _predict_short_lo = new CDataLineGraph("rt-prdt_short_lo", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _predict_short_lo->setWorld(_prc_chart->getCoordWorld()); _predict_short_lo->SetLineColor(BGR(255, 0, 0), 1.0f); _predict_short_lo->SetStrokeWidth(.2f); _predict_short_lo->GetGraphData()->SetSize(180); g = InsertNext(g->GetGlyphTreeIter(), _predict_short_lo); _predict_short_he = new CDataLineGraph("rt-prdt_short_he", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _predict_short_he->setWorld(_prc_chart->getCoordWorld()); _predict_short_he->SetLineColor(BGR(0, 255, 0), 1.0f); _predict_short_he->SetStrokeWidth(.2f); _predict_short_he->GetGraphData()->SetSize(180); g = InsertNext(g->GetGlyphTreeIter(), _predict_short_he); _predict_long_lo = new CDataLineGraph("rt-prdt_long_lo", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _predict_long_lo->setWorld(_prc_chart->getCoordWorld()); _predict_long_lo->SetLineColor(BGR(255, 0, 0), 1.0f); _predict_long_lo->SetStrokeWidth(.2f); _predict_long_lo->GetGraphData()->SetSize(180); g = InsertNext(g->GetGlyphTreeIter(), _predict_long_lo); _predict_long_he = new CDataLineGraph("rt-prdt_long_he", CDataLineGraph::GEOMETRY_PATH_TYPE_LINE, false, false); _predict_long_he->setWorld(_prc_chart->getCoordWorld()); _predict_long_he->SetLineColor(BGR(255, 0, 0), 1.0f); _predict_long_he->SetStrokeWidth(.2f); _predict_long_he->GetGraphData()->SetSize(180); g = InsertNext(g->GetGlyphTreeIter(), _predict_long_he); } catch(...) { return (-1); } return S_OK; }
void PSI6Renderer::parallelEncode(int TID, size_t bufferSize, char* buffer){ std::stringstream filename; cv::VideoWriter videoWriter; const COMPONENT comp = component; const double ISO_SCALER = std::min(W / X, H / Y); const double C_SCALE = 255.0 / 2.0; const double CIRCLE_RADIUS = R * ISO_SCALER; filename << PSI6Renderer::outputFile; filename << "-"; filename << TID; filename << ".avi"; uint32_t particleSize = frameSize / N; videoWriter.open(filename.str(), CV_FOURCC('X','V','I','D'), 60 , cv::Size(W, H), true); if(videoWriter.isOpened()){ BOOST_LOG_TRIVIAL(info) << "Thread " << TID << " opened " << filename.str() << " for writing " << (bufferSize / frameSize) << " frames."; } else { BOOST_LOG_TRIVIAL(error) << "Failed to open output video file in thread " << TID; } cv::Mat BGR(H, W, CV_8UC3); for(uint32_t frameBasePosition = 0; frameBasePosition < bufferSize; frameBasePosition+= frameSize){ cv::Mat image = cv::Mat::zeros(H, W, CV_8UC3); for(uint32_t particleOffset = 0; particleOffset < frameSize; particleOffset += particleSize){ double x = 0; double y = 0; double re = 0; double im = 0; uint32_t pos = frameBasePosition + particleOffset; x = *((double*)(buffer + pos + 0 * sizeof(double))); y = *((double*)(buffer + pos + 1 * sizeof(double))); re = *((double*)(buffer + pos + 2 * sizeof(double))); im = *((double*)(buffer + pos + 3 * sizeof(double))); x = x * ISO_SCALER; y = H - y * ISO_SCALER; re = (re + 1) * C_SCALE; im = (im + 1) * C_SCALE; if(comp == REAL) { cv::circle(image, cv::Point(x, y), CIRCLE_RADIUS, cv::Scalar(re, 255, 255), CV_FILLED, CV_AA, 0); } else { cv::circle(image, cv::Point(x, y), CIRCLE_RADIUS, cv::Scalar(im, 255, 255), CV_FILLED, CV_AA, 0); } } cv::cvtColor(image, BGR, CV_HSV2BGR); videoWriter << BGR; } free(buffer); BOOST_LOG_TRIVIAL(info) << "Thread " << TID << " finished."; }