当前位置: 首页>>代码示例>>C++>>正文


C++ ColorList类代码示例

本文整理汇总了C++中ColorList的典型用法代码示例。如果您正苦于以下问题:C++ ColorList类的具体用法?C++ ColorList怎么用?C++ ColorList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ColorList类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateGradientColors

void Serializer::updateGradientColors(const ColorList& colors)
{
	VColorStop* grStop;
	uint itemsCount = m_Doc.Items->count();
	for (uint c=0; c < itemsCount; ++c)
	{
		PageItem *ite = m_Doc.Items->at(c);
		QList<VColorStop*> cstops = ite->fill_gradient.colorStops();
		for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
		cstops = ite->stroke_gradient.colorStops();
		for (uint cst = 0; cst < ite->stroke_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
		cstops = ite->mask_gradient.colorStops();
		for (uint cst = 0; cst < ite->mask_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
	}
	uint masterItemsCount =  m_Doc.MasterItems.count();
	for (uint c=0; c < masterItemsCount; ++c)
	{
		PageItem *ite = m_Doc.MasterItems.at(c);
		QList<VColorStop*> cstops = ite->fill_gradient.colorStops();
		for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
		cstops = ite->stroke_gradient.colorStops();
		for (uint cst = 0; cst < ite->stroke_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
		cstops = ite->mask_gradient.colorStops();
		for (uint cst = 0; cst < ite->mask_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
	}
	uint frameItemsCount = m_Doc.FrameItems.count();
	for (uint c=0; c < frameItemsCount; ++c)
	{
		PageItem *ite = m_Doc.FrameItems.at(c);
		QList<VColorStop*> cstops = ite->fill_gradient.colorStops();
		for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
		cstops = ite->stroke_gradient.colorStops();
		for (uint cst = 0; cst < ite->stroke_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
		cstops = ite->mask_gradient.colorStops();
		for (uint cst = 0; cst < ite->mask_gradient.Stops(); ++cst)
		{
			grStop = cstops.at(cst);
			if (colors.contains(grStop->name))
				grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
		}
	}
	QStringList patterns =m_Doc.docPatterns.keys();
	for (int c = 0; c < patterns.count(); ++c)
	{
		ScPattern& pa = m_Doc.docPatterns[patterns[c]];
		for (int o = 0; o < pa.items.count(); o++)
		{
			PageItem *ite = pa.items.at(o);
			QList<VColorStop*> cstops = ite->fill_gradient.colorStops();
			for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
			{
				grStop = cstops.at(cst);
				if (colors.contains(grStop->name))
					grStop->color = SetColor(&m_Doc, grStop->name, grStop->shade);
			}
			cstops = ite->stroke_gradient.colorStops();
			for (uint cst = 0; cst < ite->stroke_gradient.Stops(); ++cst)
			{
				grStop = cstops.at(cst);
				if (colors.contains(grStop->name))
//.........这里部分代码省略.........
开发者ID:moceap,项目名称:scribus,代码行数:101,代码来源:serializer.cpp

示例2: handler

void Serializer::serializeObjects(const Selection& selection, SaxHandler& outputhandler)
{
	Xml_attr attr;
	UniqueID handler( & outputhandler );
	handler.beginDoc();
	handler.begin("SCRIBUSFRAGMENT", attr);
	ScribusDoc* doc = selection.itemAt(0)->doc();
	
	
	QMap<QString,int>::Iterator itf;
	for (itf = doc->UsedFonts.begin(); itf != doc->UsedFonts.end(); ++itf)
	{
		attr["name"] = itf.key();
		handler.beginEnd("font", attr);
	}
	
	ColorList usedColors;
	doc->getUsedColors(usedColors, false);
	ColorList::Iterator itc;
	for (itc = usedColors.begin(); itc != usedColors.end(); ++itc)
	{
		Xml_attr cattr;
		cattr["name"] = itc.key();
		if (doc->PageColors[itc.key()].getColorModel() == colorModelRGB)
			cattr["RGB"] = doc->PageColors[itc.key()].nameRGB();
		else
			cattr["CMYK"] = doc->PageColors[itc.key()].nameCMYK();
		cattr["Spot"] = toXMLString(doc->PageColors[itc.key()].isSpotColor());
		cattr["Register"] = toXMLString(doc->PageColors[itc.key()].isRegistrationColor());
		handler.beginEnd("color", cattr);
	}
	
	ResourceCollection lists;
	for (int i=0; i < doc->Items->count(); ++i)
		doc->Items->at(i)->getNamedResources(lists);
	
	QList<QString>::Iterator it;
	QList<QString> names = lists.styleNames();
	for (it = names.begin(); it != names.end(); ++it)
		doc->paragraphStyles().get(*it).saxx(handler);

	names = lists.charStyleNames();
	for (it = names.begin(); it != names.end(); ++it)
		doc->charStyles().get(*it).saxx(handler);
	
	names = lists.lineStyleNames();
	for (it = names.begin(); it != names.end(); ++it)
	{
		Xml_attr multiattr;
		multiattr["Name"] = *it;
		handler.begin("MultiLine", multiattr);		
		multiLine ml = doc->MLineStyles[*it];
		
		multiLine::Iterator itMU2;
		for (itMU2 = ml.begin(); itMU2 != ml.end(); ++itMU2)
		{
			Xml_attr lineattr;
			lineattr["Color"] = (*itMU2).Color;
			lineattr["Shade"] = toXMLString((*itMU2).Shade);
			lineattr["Dash"] = toXMLString((*itMU2).Dash);
			lineattr["LineEnd"] = toXMLString((*itMU2).LineEnd);
			lineattr["LineJoin"] = toXMLString((*itMU2).LineJoin);
			lineattr["Width"] = toXMLString((*itMU2).Width);
			handler.beginEnd("SubLine", lineattr);
		}
		handler.end("MultiLine");
	}

	/*	names = lists.patterns();
	for (it = names.begin(); it != names.end(); ++it)
		doc->patterns[*it].saxx(handler);
*/
/*
	QStringList patterns = doc->getUsedPatternsSelection((Selection*)&selection);
	for (int c = 0; c < patterns.count(); ++c)
	{
		ScPattern& pa = doc->docPatterns[patterns[c]];
		Xml_attr cattr;
		cattr["Name"] = patterns[c];
		cattr["scaleX"] = toXMLString(pa.scaleX);
		cattr["scaleY"] = toXMLString(pa.scaleY);
		cattr["width"] = toXMLString(pa.width);
		cattr["height"] = toXMLString(pa.height);
		cattr["xoffset"] = toXMLString(pa.xoffset);
		cattr["yoffset"] = toXMLString(pa.yoffset);
		handler.begin("Pattern", cattr);
		for (int o = 0; o < pa.items.count(); o++)
		{
			pa.items.at(o)->saxx(handler);
		}
		handler.end("Pattern");
	}
*/
	for (int i=0; i < doc->Items->count(); ++i)
	{
		int k = selection.findItem(doc->Items->at(i));
		if (k >=0)
			doc->Items->at(i)->saxx(handler);
	}

//.........这里部分代码省略.........
开发者ID:moceap,项目名称:scribus,代码行数:101,代码来源:serializer.cpp

示例3: importColorsFromFile

bool importColorsFromFile(QString fileName, ColorList &EditColors, QHash<QString, VGradient> *dialogGradients, bool merge)
{
	if (fileName.isEmpty())
		return false;
	int oldCount = EditColors.count();

	QFileInfo fi = QFileInfo(fileName);
	QString ext = fi.suffix().toLower();
	if (extensionIndicatesEPSorPS(ext))
	{
		PaletteLoader_PS psPalLoader;
		psPalLoader.setupTargets(&EditColors, dialogGradients);
		return psPalLoader.importFile(fileName, merge);
	}
	else
	{
		QStringList allFormatsV = LoadSavePlugin::getExtensionsForColors();
		if (allFormatsV.contains(ext))
		{
			FileLoader fl(fileName);
			int testResult = fl.testFile();
			if (testResult != -1)
			{
				ColorList LColors;
				if (fl.readColors(LColors))
				{
					ColorList::Iterator it;
					for (it = LColors.begin(); it != LColors.end(); ++it)
					{
						EditColors.tryAddColor(it.key(), it.value());
					}
					return (EditColors.count() != oldCount);
				}
			}
		}
		if (ext == "acb")			// Adobe color book format
		{
			PaletteLoader_Adobe_acb adobePalLoader;
			if (adobePalLoader.isFileSupported(fileName))
			{
				adobePalLoader.setupTargets(&EditColors, dialogGradients);
				return adobePalLoader.importFile(fileName, merge);
			}

			PaletteLoader_Autocad_acb autocadPalLoder;
			if (autocadPalLoder.isFileSupported(fileName))
			{
				autocadPalLoder.setupTargets(&EditColors, dialogGradients);
				return autocadPalLoder.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "aco")			// Adobe color swatch format
		{
			PaletteLoader_Adobe_aco adobePalLoader;
			if (adobePalLoader.isFileSupported(fileName))
			{
				adobePalLoader.setupTargets(&EditColors, dialogGradients);
				return adobePalLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "ase")			// Adobe swatch exchange format
		{
			PaletteLoader_Adobe_ase adobePalLoader;
			if (adobePalLoader.isFileSupported(fileName))
			{
				adobePalLoader.setupTargets(&EditColors, dialogGradients);
				return adobePalLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "cxf")			// Adobe swatch exchange format
		{
			PaletteLoader_CxF cxfLoader;
			if (cxfLoader.isFileSupported(fileName))
			{
				cxfLoader.setupTargets(&EditColors, dialogGradients);
				return cxfLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "skp")			// Sk1 palette
		{
			PaletteLoader_sK1 sk1PalLoader;
			if (sk1PalLoader.isFileSupported(fileName))
			{
				sk1PalLoader.setupTargets(&EditColors, dialogGradients);
				return sk1PalLoader.importFile(fileName, merge);
			}
			return false;
		}
		else if (ext == "sbz")
		{
			PaletteLoader_Swatchbook swatchbookLoader;
			if (swatchbookLoader.isFileSupported(fileName))
			{
				swatchbookLoader.setupTargets(&EditColors, dialogGradients);
				return swatchbookLoader.importFile(fileName, merge);
			}
//.........这里部分代码省略.........
开发者ID:HOST-Oman,项目名称:scribus,代码行数:101,代码来源:util_color.cpp

示例4: importColorsFromFile

bool importColorsFromFile(QString fileName, ColorList &EditColors)
{
    int oldCount = EditColors.count();
    if (!fileName.isEmpty())
    {
        QFileInfo fi = QFileInfo(fileName);
        QString ext = fi.suffix().toLower();
        if (extensionIndicatesEPSorPS(ext) || (ext == "ai"))
        {
            QString tmp, tmp2, FarNam;
            double c, m, y, k;
            ScColor cc;
            QFile f(fileName);
            if (f.open(QIODevice::ReadOnly))
            {
                bool isAtend = false;
                QDataStream ts(&f);
                while (!ts.atEnd())
                {
                    tmp = readLinefromDataStream(ts);
                    if ((tmp.startsWith("%%CMYKCustomColor")) || (tmp.startsWith("%%CMYKProcessColor")))
                    {
                        if (tmp.contains("(atend)"))
                            isAtend = true;
                        else
                        {
                            if (tmp.startsWith("%%CMYKCustomColor"))
                                tmp = tmp.remove(0,18);
                            else if (tmp.startsWith("%%CMYKProcessColor"))
                                tmp = tmp.remove(0,19);
                            ScTextStream ts2(&tmp, QIODevice::ReadOnly);
                            ts2 >> c >> m >> y >> k;
                            FarNam = ts2.readAll();
                            FarNam = FarNam.trimmed();
                            FarNam = FarNam.remove(0,1);
                            FarNam = FarNam.remove(FarNam.length()-1,1);
                            FarNam = FarNam.simplified();
                            cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
                            cc.setSpotColor(true);
                            if ((!EditColors.contains(FarNam)) && (!FarNam.isEmpty()))
                                EditColors.insert(FarNam, cc);
                            while (!ts.atEnd())
                            {
                                quint64 oldPos = ts.device()->pos();
                                tmp = readLinefromDataStream(ts);
                                if (!tmp.startsWith("%%+"))
                                {
                                    ts.device()->seek(oldPos);
                                    break;
                                }
                                tmp = tmp.remove(0,3);
                                ScTextStream ts2(&tmp, QIODevice::ReadOnly);
                                ts2 >> c >> m >> y >> k;
                                FarNam = ts2.readAll();
                                FarNam = FarNam.trimmed();
                                FarNam = FarNam.remove(0,1);
                                FarNam = FarNam.remove(FarNam.length()-1,1);
                                FarNam = FarNam.simplified();
                                cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
                                cc.setSpotColor(true);
                                if ((!EditColors.contains(FarNam)) && (!FarNam.isEmpty()))
                                    EditColors.insert(FarNam, cc);
                            }
                        }
                    }
                    if (tmp.startsWith("%%RGBCustomColor"))
                    {
                        if (tmp.contains("(atend)"))
                            isAtend = true;
                        else
                        {
                            tmp = tmp.remove(0,17);
                            ScTextStream ts2(&tmp, QIODevice::ReadOnly);
                            ts2 >> c >> m >> y;
                            FarNam = ts2.readAll();
                            FarNam = FarNam.trimmed();
                            FarNam = FarNam.remove(0,1);
                            FarNam = FarNam.remove(FarNam.length()-1,1);
                            FarNam = FarNam.simplified();
                            cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
                            if ((!EditColors.contains(FarNam)) && (!FarNam.isEmpty()))
                                EditColors.insert(FarNam, cc);
                            while (!ts.atEnd())
                            {
                                quint64 oldPos = ts.device()->pos();
                                tmp = readLinefromDataStream(ts);
                                if (!tmp.startsWith("%%+"))
                                {
                                    ts.device()->seek(oldPos);
                                    break;
                                }
                                tmp = tmp.remove(0,3);
                                ScTextStream ts2(&tmp, QIODevice::ReadOnly);
                                ts2 >> c >> m >> y;
                                FarNam = ts2.readAll();
                                FarNam = FarNam.trimmed();
                                FarNam = FarNam.remove(0,1);
                                FarNam = FarNam.remove(FarNam.length()-1,1);
                                FarNam = FarNam.simplified();
                                cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
//.........这里部分代码省略.........
开发者ID:pvanek,项目名称:scribus-cuba-1.5.0,代码行数:101,代码来源:util_color.cpp

示例5: main

int main(int argc, char** argv) {
  init(argc, argv);

  if (argc != 3) {
    google::ShowUsageWithFlags(argv[0]);
    return 1;
  }

  std::string tracks_file = argv[1];
  std::string image_format = argv[2];
  std::string output_format = FLAGS_output_format;

  bool ok;

  TrackList<DrawerPointer> tracks;

  if (FLAGS_similarity) {
    // Load tracks.
    TrackList<SiftPosition> sift_tracks;
    SiftPositionReader feature_reader;
    ok = loadTrackList(tracks_file, sift_tracks, feature_reader);
    CHECK(ok) << "Could not load tracks";

    // Convert SIFT features to generic drawable features.
    siftPositionTracksToDrawers(sift_tracks, tracks);
  } else if (FLAGS_scale) {
    // Load tracks.
    TrackList<ScaleSpacePosition> scale_tracks;
    ScaleSpacePositionReader feature_reader;
    ok = loadTrackList(tracks_file, scale_tracks, feature_reader);
    CHECK(ok) << "Could not load tracks";

    // Convert SIFT features to generic drawable features.
    scaleFeatureTracksToDrawers(scale_tracks, tracks, FLAGS_radius);
  } else {
    // Load tracks.
    TrackList<cv::Point2d> point_tracks;
    ImagePointReader<double> feature_reader;
    ok = loadTrackList(tracks_file, point_tracks, feature_reader);
    CHECK(ok) << "Could not load tracks";

    // Convert SIFT features to generic drawable features.
    translationTracksToDrawers(point_tracks, tracks, FLAGS_radius);
  }

  LOG(INFO) << "Loaded " << tracks.size() << " tracks";

  // Make a list of random colors.
  typedef std::vector<cv::Scalar> ColorList;
  ColorList colors;
  for (int i = 0; i < int(tracks.size()); i += 1) {
    colors.push_back(randomColor(BRIGHTNESS, SATURATION));
  }

  // Iterate through frames in which track was observed.
  TrackListTimeIterator<DrawerPointer> frame(tracks, 0);

  while (!frame.end()) {
    // Get the current time.
    int t = frame.t();

    // Load the image.
    cv::Mat color_image;
    cv::Mat gray_image;
    ok = readImage(makeFilename(image_format, t), color_image, gray_image);
    CHECK(ok) << "Could not read image";

    // Get the features.
    typedef std::map<int, DrawerPointer> FeatureSet;
    FeatureSet features;
    frame.getPoints(features);

    // Draw each one with its color.
    drawFeatures(color_image, features, colors);

    if (FLAGS_save) {
      std::string output_file = makeFilename(output_format, t);
      ok = cv::imwrite(output_file, color_image);
      CHECK(ok) << "Could not save image";
    }

    if (FLAGS_display) {
      cv::imshow("tracks", color_image);
      cv::waitKey(10);
    }

    ++frame;
  }

  return 0;
}
开发者ID:jvlmdr,项目名称:non-rigid-tracking,代码行数:91,代码来源:visualize_tracks.cpp

示例6: main

int main(void)
{
    ALLEGRO_COLOR background, active, inactive, info;
    old_dialog = NULL;
    cur_dialog = NULL;
    bool redraw = false;
    bool close_log = false;
    bool message_log = true;

    if (!al_init()) {
        abort_example("Could not init Allegro.\n");
    }

    //open_log();
    log_printf("Starting up log window.\n");

    al_init_image_addon();
    al_init_font_addon();
    al_init_ttf_addon();
    al_init_primitives_addon();

    background = al_map_rgb(0,0,98);
    active = al_color_name("white");
    inactive = al_color_name("gray");
    info = al_color_name("red");

    user_config.save_values();
    user_config.load_file();
    user_config.retrieve_values();

    if((!user_config.map_path.empty()) && user_config.map_autoload)
    {
        populate_filenames(user_config.map_path, &path_list);
        load_bitmaps(&path_list, &map_list);
    }

    al_install_mouse();
    al_install_keyboard();

    al_set_new_display_flags(ALLEGRO_RESIZABLE);
    display = al_create_display(user_config.res_x, user_config.res_y);
    if (!display) {
        log_printf("failure.\n");
        abort_example("Error creating display\n");
        return 1;
    }
    ALLEGRO_BITMAP * isoicon = al_load_bitmap("isoworld/isoWorld.png");
    if(isoicon) {
        al_set_display_icon(display, isoicon);
    }
    al_set_window_title(display, "IsoWorld");

    log_printf("success.\n");

    log_printf("Loading font '%s'...", "isoworld/DejaVuSans.ttf");
    user_config.font = al_load_font("isoworld/DejaVuSans.ttf", 14, 0);
    if (!user_config.font) {
        log_printf("failure.\n");
        abort_example("Error loading isoworld/DejaVuSans.ttf\n");
        return 1;
    }
    log_printf("success.\n");

    timer = al_create_timer(1.0 / 30);
    network_timer = al_create_timer(1.0);
    log_printf("Starting main loop.\n");
    allegro_queue = al_create_event_queue();
    al_register_event_source(allegro_queue, al_get_keyboard_event_source());
    al_register_event_source(allegro_queue, al_get_mouse_event_source());
    al_register_event_source(allegro_queue, al_get_display_event_source(display));
    al_register_event_source(allegro_queue, al_get_timer_event_source(timer));
    al_register_event_source(allegro_queue, al_get_timer_event_source(network_timer));
    if (textlog) {
        al_register_event_source(allegro_queue, al_get_native_text_log_event_source(
            textlog));
    }
    al_start_timer(timer);
    al_start_timer(network_timer);

    initializeAgui();
    add_widgets();

    MapSection test_map;

    test_map.set_size(user_config.map_width, user_config.map_height);

    minimap.reload();

    test_map.load_tilesets("isoworld/tilesets.ini");
    main_screen->UpdateTilesetList(&test_map);

    test_map.board_center_x = 0;
    test_map.board_top_y = 0;

    load_detailed_tiles(path_list.elevation_map, &test_map);

    int selection = 0;

    bool mapmove = 0;
    bool rightmove = 0;
//.........这里部分代码省略.........
开发者ID:DFHack,项目名称:isoworld,代码行数:101,代码来源:main.cpp


注:本文中的ColorList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。