// the *other* style menu background void menu_background2_create(texture *tex, int w, int h) { image img; image_create(&img, w, h); image_clear(&img, COLOR_MENU_BG); for(int x = 5; x < w; x += 5) { image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE2); } for(int y = 4; y < h; y += 5) { image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE2); } image_rect(&img, 1, 1, w-2, h-2, COLOR_MENU_BORDER2); image_rect(&img, 0, 0, w-2, h-2, COLOR_MENU_BORDER1); texture_create_from_img(tex, &img); image_free(&img); }
component* textinput_create(const text_settings *tconf, const char *text, const char *initialvalue) { component *c = widget_create(); textinput *tb = malloc(sizeof(textinput)); memset(tb, 0, sizeof(textinput)); tb->text = strdup(text); memcpy(&tb->tconf, tconf, sizeof(text_settings)); tb->pos = &tb->pos_; // Background for field int tsize = text_char_width(&tb->tconf); image img; image_create(&img, 15*tsize+2, tsize+3); image_clear(&img, COLOR_MENU_BG); image_rect(&img, 0, 0, 15*tsize+1, tsize+2, COLOR_MENU_BORDER); surface_create_from_image(&tb->sur, &img); image_free(&img); // Copy over the initial value memcpy(tb->buf, initialvalue, strlen(initialvalue)+1); // Widget stuff widget_set_obj(c, tb); widget_set_render_cb(c, textinput_render); widget_set_event_cb(c, textinput_event); widget_set_tick_cb(c, textinput_tick); widget_set_free_cb(c, textinput_free); return c; }
//***************************************************************************** // PRIVATE METHOD: ossimAtbController::initializeRemappers() // //***************************************************************************** void ossimAtbController::initializeRemappers() { static const char MODULE[] = "ossimAtbController::initializeRemappers()"; if (traceExec()) CLOG << "entering..." << endl; int num_images = getNumberOfInputs(); //*** // Fetch the overall mosaic bounding rect: //*** ossimGridRemapSource* remapper = PTR_CAST(ossimGridRemapSource, getInput(0)); theBoundingRect = remapper->getBoundingRect(); for (int src=1; src<num_images; src++) { theBoundingRect = theBoundingRect.combine(remapper->getBoundingRect()); } //*** // Loop over each contribution image source chain to fetch each image // bounding rect: //*** double dx_ul, dy_ul, dx_lr, dy_lr; double grid_ul_x, grid_ul_y, grid_lr_x, grid_lr_y; for (int src=0; src<num_images; src++) { remapper = PTR_CAST(ossimGridRemapSource, getInput(src)); ossimDrect image_rect (remapper->getBoundingRect()); //*** // Arrive at the number of grid posts from mosaic origin to image's grid // UL and LR corners: //*** dx_ul = (image_rect.ul().x - theBoundingRect.ul().x)/theGridSpacing.x; dy_ul = (image_rect.ul().y - theBoundingRect.ul().y)/theGridSpacing.y; dx_lr = (image_rect.lr().x - theBoundingRect.lr().x)/theGridSpacing.x; dy_lr = (image_rect.lr().y - theBoundingRect.lr().y)/theGridSpacing.y; //*** // Establish the view coordinates for the adjusted image grid: //*** grid_ul_x = theBoundingRect.ul().x + ceil(dx_ul)*theGridSpacing.x; grid_ul_y = theBoundingRect.ul().y + ceil(dy_ul)*theGridSpacing.y; grid_lr_x = theBoundingRect.lr().x + floor(dx_lr)*theGridSpacing.x; grid_lr_y = theBoundingRect.lr().y + floor(dy_lr)*theGridSpacing.y; //*** // Have the remapper initialize a new grid with the given rectangle and // spacing: //*** ossimDrect grid_rect (grid_ul_x, grid_ul_y, grid_lr_x, grid_lr_y); remapper->initialize(grid_rect, theGridSpacing); } if (traceExec()) CLOG << "returning..." << endl; return; }
/* method */ bool Validate( HeadPoseParticle& head_pose_particle, const HeadPoseParticleEvalBase& eval_base ) { CorrectDirection( head_pose_particle ); cv::Rect_<int> image_rect( eval_base.offset_x(), eval_base.offset_y(), eval_base.image().cols, eval_base.image().rows ); cv::Point2i particle_lu( head_pose_particle.x(), head_pose_particle.y() ); cv::Point2i particle_rl( head_pose_particle.x() + head_pose_particle.s() - 1, head_pose_particle.y() + head_pose_particle.s() - 1 ); return ( image_rect.contains( particle_lu ) && image_rect.contains( particle_rl ) && head_pose_particle.s() >= s_min_ && head_pose_particle.s() <= s_max_ ); }
void menu_background_create(texture *tex, int w, int h) { image img; image_create(&img, w, h); image_clear(&img, COLOR_MENU_BG); for(int x = 7; x < w; x += 8) { image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE); } for(int y = 7; y < h; y += 8) { image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE); } image_rect(&img, 0, 0, w-1, h-1, COLOR_MENU_BORDER); texture_create_from_img(tex, &img); image_free(&img); }
void PrettyImage::paintEvent(QPaintEvent*) { // Draw at the bottom of our area QRect image_rect(QPoint(0, 0), image_size()); image_rect.moveBottom(kImageHeight); QPainter p(this); // Draw the main image DrawThumbnail(&p, image_rect); // Draw the reflection // Figure out where to draw it QRect reflection_rect(image_rect); reflection_rect.moveTop(image_rect.bottom()); // Create the reflected pixmap QImage reflection(reflection_rect.size(), QImage::Format_ARGB32_Premultiplied); reflection.fill(palette().color(QPalette::Base).rgba()); QPainter reflection_painter(&reflection); // Set up the transformation QTransform transform; transform.scale(1.0, -1.0); transform.translate(0.0, -reflection_rect.height()); reflection_painter.setTransform(transform); QRect fade_rect(reflection.rect().bottomLeft() - QPoint(0, kReflectionHeight), reflection.rect().bottomRight()); // Draw the reflection into the buffer DrawThumbnail(&reflection_painter, reflection.rect()); // Make it fade out towards the bottom QLinearGradient fade_gradient(fade_rect.topLeft(), fade_rect.bottomLeft()); fade_gradient.setColorAt(0.0, QColor(0, 0, 0, 0)); fade_gradient.setColorAt(1.0, QColor(0, 0, 0, 128)); reflection_painter.setCompositionMode( QPainter::CompositionMode_DestinationIn); reflection_painter.fillRect(fade_rect, fade_gradient); reflection_painter.end(); // Draw the reflection on the image p.drawImage(reflection_rect, reflection); }
//***************************************************************************** // METHOD: ossimAtbController::execute() // //***************************************************************************** bool ossimAtbController::execute() { static const char MODULE[] = "ossimAtbController::execute()"; if (traceExec()) CLOG << "entering..." << endl; setPercentComplete(0.0); ossimGridRemapSource* source; //*** // First verify that all objects needed are initialized: //*** int num_images = getNumberOfInputs(); if ((!theGridRemapEngine) || (num_images < 2)) { CLOG << "WARNING: execute method was called but the controller has not " << "been properly initialized. Ignoring request..." << endl; if (traceExec()) CLOG << "returning..." << endl; return false; } //*** // establish the remap grids: //*** initializeRemappers(); setPercentComplete(10.0); //*** // Establish grid of matchpoints: //*** int numPoints = 0; ossimDpt mp_view_pt; theMatchPoints.clear(); for (mp_view_pt.line = theBoundingRect.ul().line; mp_view_pt.line <= theBoundingRect.lr().line; mp_view_pt.line += theGridSpacing.line) { for (mp_view_pt.samp = theBoundingRect.ul().samp; mp_view_pt.samp <= theBoundingRect.lr().samp; mp_view_pt.samp += theGridSpacing.samp) { ossimAtbMatchPoint* mp = new ossimAtbMatchPoint(mp_view_pt, theGridRemapEngine); theMatchPoints.push_back(mp); numPoints++; } } //*** // Loop over each matchpoint to determine which images contribute statistics: //*** setPercentComplete(20.0); for (int mp=0; mp<numPoints; mp++) { ossimDpt view_point (theMatchPoints[mp]->viewPoint()); //*** // Loop over each image source to check if point lies inside its bounding // rectangle, and add its contribution to the matchpoint's collection: //*** for (int src=0; src<num_images; src++) { source = PTR_CAST(ossimGridRemapSource, getInput(src)); if (source) { ossimDrect image_rect (source->getBoundingRect()); if (image_rect.pointWithin(view_point)) theMatchPoints[mp]->addImage(source); } } setPercentComplete(20.0 + 50.0*(mp/numPoints)); } //*** // All contributors have been included in all matchpoints' collections. // Compute the target pixel value for each matchpoint and communicate it // to the corresponding remappers: //*** for (int mp=0; mp<numPoints; mp++) { setPercentComplete(70.0 + 30.0*(mp/numPoints)); theMatchPoints[mp]->assignRemapValues(); } //*** // Finally, enable the remappers: //*** for (int src=0; src<num_images; src++) { source = PTR_CAST(ossimGridRemapSource, getInput(src)); if (source) source->enableSource(); } setPercentComplete(100.0); if (traceExec()) CLOG << "returning..." << endl; return true; }