Esempio n. 1
0
void Gui_ResultFileWriter::writeHeader(const bool detail){

    Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->replace();
    if(detail){
        fout->write("Full_Path,Valid,X,Y,ROI,Area,Radius,R,G,B,Hue,Saturation,N_in_cluster,Comment\n");
        fout->close();
    }
    else{
        fout->write("ID,File_name,N_Objects,N_Excluded,Comment,Full_Path\n");
        fout->close();
    }
}
Esempio n. 2
0
void Gui_ConfigIO::makeNewConfig(){

    m_key_file.set_integer("GUI","hello_level",m_hello_lev);
    m_key_file.set_string("GUI","last_wd", m_last_working_dir);
    m_key_file.set_boolean("Processing","Has_auto-threshold",m_opts.getHasAutoThr());
    m_key_file.set_boolean("Processing","Has_max-radius",m_opts.getHasMaxRad());
    m_key_file.set_boolean("Processing","Has_hue-filter",m_opts.getHasHueFilt());
    m_key_file.set_boolean("Processing","Has_outlier-filter",m_opts.getHasOutlierFilt());

    m_key_file.set_integer("Processing","Threshold",m_opts.getThr());
    m_key_file.set_integer("Processing","Threshold-mode",m_opts.getThrMode());

    m_key_file.set_integer("Processing","Min-rad",m_opts.getMinMaxRad().first);
    m_key_file.set_integer("Processing","Max-rad",m_opts.getMinMaxRad().second);

    m_key_file.set_integer("Processing","Hue-center",m_opts.getCenTolHue().first);
    m_key_file.set_integer("Processing","Hue-tolerance",m_opts.getCenTolHue().second);

    m_key_file.set_integer("Processing","Satur-min-saturation",m_opts.getMinMaxSat().first);
    m_key_file.set_integer("Processing","Satur-max-saturation",m_opts.getMinMaxSat().second);

    m_key_file.set_double("Processing","Likelihood-threshold",m_opts.getLikeThr());

    m_key_file.set_double("Processing","Clustering-Distance",m_opts.getClustDist());

    m_key_file.set_string("General","former_version",PACKAGE_VERSION);


    m_file = Gio::File::create_for_path(m_config_file_name.c_str());
    Glib::RefPtr< Gio::FileOutputStream > fout = m_file->replace();
    fout->write(m_key_file.to_data());
    fout->close();
}
Esempio n. 3
0
void DataValue::parsePixbuf(const ustring &text, void *value) {
	gsize size;
	guchar *buf = g_base64_decode(text.c_str(), &size);
	Glib::RefPtr<Gdk::PixbufLoader> loader = Gdk::PixbufLoader::create();
	loader->write(buf, size);
	loader->close();
	(*(TypePixbuf*)value) = loader->get_pixbuf();
	g_free(buf);
}
Esempio n. 4
0
Glib::RefPtr<Gdk::Pixbuf> LastFmPlugin::getIcon() const
{
    Glib::RefPtr<Gdk::PixbufLoader> loader = Gdk::PixbufLoader::create();
    loader->set_size(32, 32);
    loader->write((guint8*)icon, 2567);
    Glib::RefPtr<Gdk::Pixbuf> pixBuf = loader->get_pixbuf();
    loader->close();

    return pixBuf;
}
Esempio n. 5
0
Glib::RefPtr<Gdk::Pixbuf> createCoverPixBuf(const AlbumArt& albumArt, int32_t size)
{
    Glib::RefPtr<Gdk::PixbufLoader> loader = Gdk::PixbufLoader::create();
    loader->set_size(size, size);
    loader->write(&(albumArt.getData().front()), albumArt.getData().size());
    Glib::RefPtr<Gdk::Pixbuf> pixBuf = loader->get_pixbuf();
    loader->close();

    return pixBuf;
}
Esempio n. 6
0
    void Gui_ResultFileWriter::writeHeader(const bool detail,const ResultMap& res_map, const std::vector<int>& idxs){

        Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->replace();
        std::stringstream ss;
        if(detail){
                ss << "Full_Path, "<<OneObjectRow::printHeader()<<", Comment"<<std::endl;
        }
        else{
            ss<<"ID, File_name, ROI, N_Objects, N_Excluded, Cluster1, Cluster2, Cluster3, Comment, Full_Path, ClusterDetail"<<std::endl;
        }
        DEV_INFOS(ss.str());
        fout->write(ss.str());
        fout->close();
    }
Esempio n. 7
0
Glib::RefPtr<Gdk::Pixbuf> createCoverPixBufWithOverlay(const AlbumArt& albumArt, int32_t size)
{
    try
    {
        std::stringstream finalGeometry;
        finalGeometry << size << "x" << size;

        std::stringstream intermediateGeometry;
        intermediateGeometry << overlayWidth << "x" << overlayHeight << "!";
        
        std::stringstream albumArtGeometry;
        albumArtGeometry << coverWidth << "x" << coverHeight << "!";

        Magick::Blob coverImageBlob(&(albumArt.getData().front()), albumArt.getData().size());
        Magick::Image coverImage(coverImageBlob);
        coverImage.scale(Magick::Geometry(albumArtGeometry.str()));

        Magick::Blob cdCaseBlob(cdCaseData, sizeof(cdCaseData));
        Magick::Image cdCase(cdCaseBlob, Magick::Geometry(intermediateGeometry.str()), "PNG");

        Magick::Quantum maxRgb;
        {using namespace Magick; maxRgb = MaxRGB;} // Magick::MaxRGB; quits with the compile-time error "'Quantum' was not declared in this scope"
        Magick::Image result(Magick::Geometry(intermediateGeometry.str()), Magick::Color(0, 0, 0, maxRgb));
        result.composite(coverImage, coverImageOffsetX, coverImageOffsetY, Magick::CopyCompositeOp);
        result.composite(cdCase, 0, 0, Magick::OverCompositeOp);
        result.scale(Magick::Geometry(finalGeometry.str()));

        Magick::Blob data;
        result.write(&data, "PNG");

        Glib::RefPtr<Gdk::PixbufLoader> loader = Gdk::PixbufLoader::create();
        loader->set_size(size, size);
        loader->write((guint8*)data.data(), data.length());
        Glib::RefPtr<Gdk::Pixbuf> pixBuf = loader->get_pixbuf();
        loader->close();

        return pixBuf;
    }
    catch (Magick::Exception& e)
    {
        log::warn("Creating cover with overlay failed: %s", e.what());
        return createCoverPixBuf(albumArt, size);
    }
}
Esempio n. 8
0
void
StateBrush_Context::BrushConfig::load(const String &filename)
{
	clear();

	char *buffer = NULL;
	{
		Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(filename);
		goffset s = file->query_info()->get_size();
		if (s < 0) return;
		size_t size = s > INT_MAX-1 ? INT_MAX-1 : (size_t)s;
		buffer = new char[size+1];
		memset(buffer, 0, size+1);

		Glib::RefPtr<Gio::FileInputStream> stream = file->read();
		stream->read(buffer, size);
		stream->close();
	}

	const char *pos = buffer;
	if (pos != NULL) while(read_row(&pos)) { }
	free(buffer);
	this->filename = filename;
}
Esempio n. 9
0
    void Gui_ResultFileWriter::writeRows(const bool detail,const ResultMap& res_map,const std::vector<int>& idxs){
        Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->append_to();


        if(detail){
            for (auto i : idxs){
                const Result& res_ref = res_map.getResultAt(i);

                const std::string& path = (res_map.getFileFromIdx(i)->get_path());
                const std::string& comment = res_map.getCommentAt(i);

                if(!res_map.getIsNAAt(i)){
                    for (unsigned int j=0; j<res_ref.size();++j){
                        std::stringstream ss;
                        const OneObjectRow& oor = res_ref.getRow(j);
                        ss <<"\""<<path<<"\", "<< oor.print()<<", \""<<comment<<"\""<<std::endl;
                        fout->write(ss.str());
                    }
                }
            }
        }
        else{
            for (auto i : idxs){
                const Result& res_ref = res_map.getResultAt(i);
                Glib::RefPtr<Gio::File> tmp_file = res_map.getFileFromIdx(i);
                const std::vector<int> roi_keys = res_ref.getROIs();
                const std::string& comment = res_map.getCommentAt(i);

                std::map < unsigned int,std::pair<unsigned int,unsigned int> > table;
                table[0].first = res_ref.getNValid();
                table[0].second =  res_ref.size() - res_ref.getNValid();
                for(unsigned int i=0; i != (unsigned int)res_ref.size(); ++i){
                    OneObjectRow object = res_ref.getRow(i);
                    int roi = object.getROI();
                    if (roi > 0){
                        if(object.getGUIValid() && object.isValid()) //otherwise colour filters etc. don't work
                            ++(table[roi].first);
                        else
                            ++(table[roi].second);
                    }
                }


                for (auto &it : table){
                    int roi = it.first;
                    if ((table.size() == 1) || (roi >= 1)){

                        std::stringstream ss;
                        ss  <<i<<","
                            <<"\""<<tmp_file->get_basename()<<"\""<<","
                            <<roi<<",";

                        if(!res_map.getIsNAAt(i)){
                            ss<<it.second.first<<","
                            <<it.second.second<<",";
                        }
                        else{
                            ss<<"NA,NA,";
                        }
                            ss<<res_ref.getROIClusterData(roi).clusterPop(1)<<","
                            <<res_ref.getROIClusterData(roi).clusterPop(2)<<","
                            <<res_ref.getROIClusterData(roi).clusterPop(3)<<","
                            <<"\""<<comment<<"\""<<","
                            <<"\""<<tmp_file->get_path()<<"\","
                            <<"\""<<res_ref.getROIClusterData(roi).str()<<"\""<<std::endl;

                        fout->write(ss.str());
                    }
                }
            }
        }
        fout->flush ();
        fout->close();

    }
Esempio n. 10
0
void MainFrame::on_infoBTN_clicked(void)
{
	int win_w, win_h;
	m_mainframe->get_size(win_w, win_h);	
	Gtk::AboutDialog dlg;
	dlg.set_name(APP);
	dlg.set_version(VERSION);
	dlg.set_comments("OZAXE :: Open Source ACCessibilty Software.");
	dlg.set_website_label("SiteWeb");
	dlg.set_website(OZAXE_WEBSITE);
	dlg.set_copyright(COPYRIGHT);
	
	dlg.set_logo(Gdk::Pixbuf::create_from_file("ui/images/ozaxe.png"));
	//dlg.set_logo_icon_name("ozaxe-logo");
	dlg.set_icon_from_file("ui/images/ozaxeico.png");
	
	std::deque<Glib::ustring> authors;
	authors.push_back("Développeurs:");
	authors.push_back("\tChristian KAKESA <*****@*****.**>");
	authors.push_back("");
	authors.push_back("Contributeurs:");
	authors.push_back("\tAucune");
	
	std::deque<Glib::ustring> artists;
	artists.push_back("Logo:");
	artists.push_back("\tAucune");
	artists.push_back("");
	artists.push_back("Autres éléments graphiques:");
	artists.push_back("\tAucune");
	
	dlg.set_authors(authors);
	dlg.set_artists(artists);
	
	dlg.set_translator_credits(
	        "Traduction anglaise:\n"
	        "\tAucune\n"
	        "\n"
	        "Traduction allemande:\n"
	        "\tAucune\n"
	        "\n"
	        "Traduction espagnole:\n"
	        "\tAucune\n"
	        );

	try
	{
		Glib::ustring license;
		Glib::RefPtr<Glib::IOChannel> ifile = Glib::IOChannel::create_from_file("data/licenses/gpl-3.0.txt", "r");
		ifile->read_to_end(license);
		ifile->close();
		dlg.set_license(license);
	}
	catch (Glib::IOChannelError& e)	
	{
		Utils::display_error( dlg, e.what() );
	}
	catch (Glib::ConvertError& e)
	{
		Utils::display_error( dlg, e.what() );
	}
	dlg.move(win_w+15, 0);

	dlg.run();
}
Esempio n. 11
0
void Gui_ResultFileWriter::writeRows(const bool detail,const ResultMap& res_map,const std::vector<int>& idxs){
    Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->append_to();

    if(detail){
        for (auto i : idxs){
            const Result& res_ref = res_map.getResultAt(i);

            const std::string& path = (res_map.getFileFromIdx(i)->get_path());
            const std::string& comment = res_map.getCommentAt(i);

            if(!res_map.getIsNAAt(i)){
                for (unsigned int j=0; j<res_ref.size();++j){
                    std::stringstream ss;
                    const OneObjectRow& oor = res_ref.getRow(j);
                    cv::Scalar col = oor.getBGRMean();

                    cv::Point2f center = (oor.getPoint(0) + oor.getPoint(2) ) * 0.5;
                    ss  <<"\""<<path<<"\""<<","
                        <<oor.isValid()<<","
                        <<center.x<<","
                        <<center.y<<","
                        <<oor.getROI()<<","
                        <<(int)oor.getArea()<<","
                        <<oor.getRadius()<<","
                        <<col[2]<<","
                        <<col[1]<<","
                        <<col[0]<<","
                        <<oor.getHue()<<","
                        <<oor.getSat()<<","
                        <<oor.getNInClust()<<","
                        <<"\""<<comment<<"\""<<std::endl;
                    fout->write(ss.str());
                }
            }
        }
    }
    else{
        for (auto i : idxs){
            const Result& res_ref = res_map.getResultAt(i);
            Glib::RefPtr<Gio::File> tmp_file = res_map.getFileFromIdx(i);

            const std::string& comment = res_map.getCommentAt(i);

            std::stringstream ss;
            ss  <<i<<","
                <<"\""<<tmp_file->get_basename()<<"\""<<",";
            if(!res_map.getIsNAAt(i)){
                ss<<res_ref.getNValid()<<","
                <<res_ref.size() - res_ref.getNValid()<<",";
            }
            else{
                ss<<"NA,NA,";
            }
                ss<<comment<<","
                <<"\""<<tmp_file->get_path()<<"\""<<std::endl;

            fout->write(ss.str());
        }
    }
    fout->flush ();
    fout->close();

}