/** * \brief Compile the sprite. * \param f The stream in which we write the compiled sprite. * \param c The context in which the compilation is done. */ void bf::sprite::compile( compiled_file& f, compilation_context& c ) const { std::string image_path(m_image_name); if ( path_configuration::get_instance().expand_file_name(image_path) ) path_configuration::get_instance().get_relative_path(image_path); const compilation_context::rectangle r ( c.get_opaque_rectangle( *this, image_path ) ); f << image_path << m_left << m_top << m_clip_width << m_clip_height << r.left() << r.bottom() << r.right() << r.top(); bitmap_rendering_attributes::compile(f); } // sprite::compile()
void MultiresImagePlugin::LoadConfig(const YAML::Node& node, const std::string& path) { std::string path_string; node["path"] >> path_string; boost::filesystem::path image_path(path_string); if (image_path.is_complete() == false) { boost::filesystem::path base_path(path); path_string = (path / image_path.relative_path()).normalize().string(); } ui_.path->setText(path_string.c_str()); AcceptConfiguration(); }
void KeyboardDirectionDialog::createLayout() { // top box layout_.setSizeConstraint(QLayout::SetMinAndMaxSize); layout_.setContentsMargins(0, 0, 0, 0); layout_.setSpacing(0); direction_button_.setStyleSheet(KEYBOARD_DIRECTION_BUTTON_STYLE); QString image_path(":/images/about.png"); switch (direction_) { case KEYBOARD_UP: image_path = ":/images/keyboard_up.png"; break; case KEYBOARD_DOWN: image_path = ":/images/keyboard_down.png"; break; case KEYBOARD_LEFT: image_path = ":/images/keyboard_left.png"; break; case KEYBOARD_RIGHT: image_path = ":/images/keyboard_right.png"; break; default: break; } QPixmap direction_button_map(image_path); direction_button_.setIcon(QIcon(direction_button_map)); direction_button_.setIconSize(direction_button_map.size()); direction_button_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); direction_button_.setFocusPolicy(Qt::NoFocus); setMask(direction_button_map.mask()); layout_.addWidget(&direction_button_); connect(&direction_button_, SIGNAL(clicked(bool)), this, SLOT(onDirectionClicked(bool)), Qt::QueuedConnection); }
bool cSystemWatcherDrv::HandleEvent(cMessageInfo &msg, cEventInfo &evi) { cEvent event(0, msg.eventHdr->m_ProcessId); evi.time = event.GetTime(); evi.pid = event.m_pid; evi.eventType = evtUnknown; evi.objectType = objUnknown; evi.name = NULL; evi.name2 = NULL; evi.userId = 0; evi.extraData = 0; if( msg.eventHdr->m_HookID == FLTTYPE_SYSTEM ) { switch(msg.eventHdr->m_FunctionMj) { case MJ_CREATE_PROCESS_NOTIFY: { ULONG Pid = 0; PSINGLE_PARAM pParamPid = MKL_GetEventParam(msg.msg, msg.msgSize, _PARAM_OBJECT_SOURCE_ID, FALSE); if (pParamPid) Pid = *(ULONG*) pParamPid->ParamValue; PWCHAR pwchPath = NULL; PSINGLE_PARAM pParamUrl = MKL_GetEventParam(msg.msg, msg.msgSize, _PARAM_OBJECT_URL_W, FALSE); if (pParamUrl) pwchPath = (PWCHAR) pParamUrl->ParamValue; PWCHAR pwchFolder = NULL; PSINGLE_PARAM pParamFolder = MKL_GetEventParam(msg.msg, msg.msgSize, _PARAM_OBJECT_BASEPATH, FALSE); if (pParamFolder) pwchFolder = (PWCHAR) pParamFolder->ParamValue; PWCHAR pwchCmd = NULL; PSINGLE_PARAM pParamCmd = MKL_GetEventParam(msg.msg, msg.msgSize, _PARAM_OBJECT_STARTUP_STR, FALSE); if (pParamCmd) pwchCmd = (PWCHAR) pParamCmd->ParamValue; printf("create process pid %d (parent %d) from '%S'\n", Pid, msg.eventHdr->m_ProcessId, pwchPath); if (pwchFolder) printf("\tfolder: '%S'\n", pwchFolder); if (pwchCmd) printf("\tCmdLine: '%S'\n", pwchCmd); cFile image_path( &m_envhelper, pwchPath, pwchPath ); cPath working_folder(&m_envhelper, pwchFolder, pwchFolder); evi.eventType = evtProcessStart; evi.objectType = objFile; evi.extraData = Pid; evi.name = tstrdup(image_path.getFull()); return true; } case MJ_EXIT_PROCESS: { PWCHAR pwchPath = NULL; HRESULT hResult = MKL_GetProcessPath(m_driverContext, msg.msg, &pwchPath); printf("exit process pid %d, '%S'\n", msg.eventHdr->m_ProcessId, pwchPath); cFile image_path(&m_envhelper, pwchPath, pwchPath); evi.eventType = evtProcessStop; evi.objectType = objFile; evi.name = tstrdup(image_path.getFull()); pfMemFree(NULL, (void**)&pwchPath); return true; } } } if( msg.eventHdr->m_HookID == FLTTYPE_NFIOR ) { PWCHAR pwchPath = NULL; PSINGLE_PARAM pParamUrl = MKL_GetEventParam(msg.msg, msg.msgSize, _PARAM_OBJECT_URL_W, FALSE); if (pParamUrl) pwchPath = (PWCHAR)pParamUrl->ParamValue; if( msg.eventHdr->m_FunctionMj == IRP_MJ_CREATE ) { PSINGLE_PARAM pParamCtx = MKL_GetEventParam(msg.msg, msg.msgSize, _PARAM_OBJECT_CONTEXT_FLAGS, FALSE); bool fileCreated = pParamCtx && (*(ULONG *)pParamCtx->ParamValue & _CONTEXT_OBJECT_FLAG_CREATENEWOBJECT); if( !fileCreated ) return false; printf("file is created. pid %d, %S\n", msg.eventHdr->m_ProcessId, pwchPath); evi.eventType = evtCreate; } if( msg.eventHdr->m_FunctionMj == IRP_MJ_WRITE ) { printf("file is modified. pid %d, %S\n", msg.eventHdr->m_ProcessId, pwchPath); evi.eventType = evtModify; } cFile image_path(&m_envhelper, pwchPath, pwchPath); evi.objectType = objFile; evi.name = tstrdup(image_path.getFull()); return true; } return false; }
// [ref] ${VXL_HOME}/contrib/mul/msm/tools/msm_draw_points_on_image.cxx int msm_draw_points_on_image_example(int argc, char *argv[]) { vul_arg<vcl_string> curves_path("-c", "File containing curves"); vul_arg<vcl_string> pts_path("-p", "File containing points"); vul_arg<vcl_string> image_path("-i", "Image"); vul_arg<vcl_string> out_path("-o", "Output path","image+pts.eps"); vul_arg<vcl_string> line_colour("-lc", "Line colour","yellow"); vul_arg<vcl_string> pt_colour("-pc", "Point colour","none"); vul_arg<vcl_string> pt_edge_colour("-pbc", "Point border colour","none"); vul_arg<double> pt_radius("-pr", "Point radius",2.0); vul_arg<double> scale("-s", "Scaling to apply",1.0); vul_arg_parse(argc, argv); if (pts_path() == "") { local::print_usage(); return 0; } msm_curves curves; if (curves_path() != "" && !curves.read_text_file(curves_path())) vcl_cerr << "Failed to read in curves from " << curves_path() << vcl_endl; msm_points points; if (!points.read_text_file(pts_path())) { vcl_cerr << "Failed to read points from " << pts_path() << vcl_endl; return 2; } vcl_vector<vgl_point_2d<double> > pts; points.get_points(pts); //================ Attempt to load image ======== vil_image_view<vxl_byte> image; if (image_path() != "") { image = vil_load(image_path().c_str()); if (image.size() == 0) { vcl_cout << "Failed to load image from " << image_path() << vcl_endl; return 1; } vcl_cout << "Image is " << image << vcl_endl; } if (scale() > 1.001 || scale() < 0.999) { // Scale image and points vil_image_view<vxl_byte> image2; image2.deep_copy(image); if (scale() < 0.51) vil_gauss_filter_2d(image, image2, 1.0, 3); vil_resample_bilin(image2, image, int(0.5 + scale() * image.ni()), int(0.5 + scale() * image.nj())); points.scale_by(scale()); } // Compute bounding box of points vgl_box_2d<double> bbox = points.bounds(); bbox.scale_about_centroid(1.05); // Add a border // If an image is supplied, use that to define bounding box if (image.size() > 0) { bbox = vgl_box_2d<double>(0, image.ni(), 0,image.nj()); } vgl_point_2d<double> blo = bbox.min_point(); // Translate all points to allow for shift of origin points.translate_by(-blo.x(), -blo.y()); mbl_eps_writer writer(out_path().c_str(), bbox.width(), bbox.height()); if (image.size() > 0) writer.draw_image(image, 0, 0, 1, 1); if (pt_colour() != "none") { // Draw all the points writer.set_colour(pt_colour()); msm_draw_points_to_eps(writer, points, pt_radius()); } if (pt_edge_colour() != "none") { // Draw disks around all the points writer.set_colour(pt_edge_colour()); msm_draw_points_to_eps(writer, points, pt_radius(), false); } if (curves.size() > 0 && line_colour() != "none") { // Draw all the lines writer.set_colour(line_colour()); msm_draw_shape_to_eps(writer, points, curves); } writer.close(); vcl_cout << "Graphics saved to " << out_path() << vcl_endl; return 0; }