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


C++ ColorMap::Load方法代码示例

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


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

示例1: MakeColorMap

static void MakeColorMap (ColorMap& cmap)
{
  cmap.Load("copper-256"); 			       // load a default colormap
  if (! cmap) Matpack.Error("Can't load colormap");
  cmap.Reverse();					      // reverse ordering
  int i, n = cmap.Size();				   // change colormap now
  for (i = 0;  i < 20; i++) cmap[i] = ColorB(0,100+2*i,160+2*i);         // water
  for (i = 20; i < 80; i++) cmap[i] = ColorB(2*i+20,2*i+20,i/2+10);   // mangrove
  for (i = 1;  i < 60; i++) cmap[n-i] = ColorB(255-i,250-i,250-2*i);      // snow
}
开发者ID:lucafuji,项目名称:Gene-Correlation,代码行数:10,代码来源:fractal-surface.cpp

示例2: RenderBitmap

void vtElevLayer::RenderBitmap()
{
	if (!m_pGrid)
		return;

	// flag as being rendered
	m_bNeedsDraw = false;

	// safety check
	if (m_ImageSize.x == 0 || m_ImageSize.y == 0)
		return;

	DetermineMeterSpacing();

	clock_t tm1 = clock();

#if 0
	// TODO: re-enable this friendly cancel behavior
	if (UpdateProgressDialog(j*100/m_ImageSize.y))
	{
		wxString msg = _("Turn off displayed elevation for elevation layers?");
		if (wxMessageBox(msg, _T(""), wxYES_NO) == wxYES)
		{
			m_draw.m_bShowElevation = false;
			CloseProgressDialog();
			return;
		}
		else
			ResumeProgressDialog();
	}
#endif
	ColorMap cmap;
	vtString cmap_fname = m_draw.m_strColorMapFile;
	vtString cmap_path = FindFileOnPaths(vtGetDataPath(), "GeoTypical/" + cmap_fname);
	bool bLoaded = false;
	if (cmap_path != "")
	{
		if (cmap.Load(cmap_path))
			bLoaded = true;
	}
	if (!bLoaded)
		SetupDefaultColors(cmap);

	bool has_invalid = m_pGrid->ColorDibFromElevation(m_pBitmap, &cmap,
		8000, RGBi(255,0,0), progress_callback_minor);

	if (m_draw.m_bShadingQuick)
		m_pGrid->ShadeQuick(m_pBitmap, SHADING_BIAS, true, progress_callback_minor);
	else if (m_draw.m_bShadingDot)
	{
		// Quick and simple sunlight vector
		FPoint3 light_dir = LightDirection(m_draw.m_iCastAngle, m_draw.m_iCastDirection);

		if (m_draw.m_bCastShadows)
			m_pGrid->ShadowCastDib(m_pBitmap, light_dir, 1.0f,
				m_draw.m_fAmbient, progress_callback_minor);
		else
			m_pGrid->ShadeDibFromElevation(m_pBitmap, light_dir, 1.0f,
				m_draw.m_fAmbient, m_draw.m_fGamma, true, progress_callback_minor);
	}

	m_pBitmap->ContentsChanged();

	if (has_invalid && m_draw.m_bDoMask)
	{
		m_pMask = new wxMask(*m_pBitmap->m_pBitmap, wxColour(255, 0, 0));
		m_pBitmap->m_pBitmap->SetMask(m_pMask);
		m_bHasMask = true;
	}
	else
		m_bHasMask = false;

	clock_t tm2 = clock();
	float time = ((float)tm2 - tm1)/CLOCKS_PER_SEC;
	VTLOG("RenderBitmap: %.3f seconds.\n", time);

	m_bBitmapRendered = true;
}
开发者ID:kamalsirsa,项目名称:vtp,代码行数:78,代码来源:ElevLayer.cpp

示例3: WriteElevationTileset

bool vtElevLayer::WriteElevationTileset(TilingOptions &opts, BuilderView *pView)
{
	// Avoid trouble with '.' and ',' in Europe
	ScopedLocale normal_numbers(LC_NUMERIC, "C");

	// Check that options are valid
	CheckCompressionMethod(opts);

	// grid size
	int base_tilesize = opts.lod0size;

	int gridcols, gridrows;
	m_pGrid->GetDimensions(gridcols, gridrows);

	DRECT area = m_pGrid->GetEarthExtents();
	DPoint2 tile_dim(area.Width()/opts.cols, area.Height()/opts.rows);
	DPoint2 cell_size = tile_dim / base_tilesize;

	const vtProjection &proj = m_pGrid->GetProjection();
	vtString units = GetLinearUnitName(proj.GetUnits());
	units.MakeLower();
	int zone = proj.GetUTMZone();
	vtString crs;
	if (proj.IsGeographic())
		crs = "LL";
	else if (zone != 0)
		crs = "UTM";
	else
		crs = "Other";

	// Try to create directory to hold the tiles
	vtString dirname = opts.fname;
	RemoveFileExtensions(dirname);
	if (!vtCreateDir(dirname))
		return false;

	// We won't know the exact height extents until the tiles have generated,
	//  so gather extents as we produce the tiles and write the INI later.
	float minheight = 1E9, maxheight = -1E9;

	ColorMap cmap;
	vtElevLayer::SetupDefaultColors(cmap);	// defaults
	vtString dirname_image = opts.fname_images;
	RemoveFileExtensions(dirname_image);
	if (opts.bCreateDerivedImages)
	{
		if (!vtCreateDir(dirname_image))
			return false;

		vtString cmap_fname = opts.draw.m_strColorMapFile;
		vtString cmap_path = FindFileOnPaths(vtGetDataPath(), "GeoTypical/" + cmap_fname);
		if (cmap_path == "")
			DisplayAndLog("Couldn't find color map.");
		else
		{
			if (!cmap.Load(cmap_path))
				DisplayAndLog("Couldn't load color map.");
		}
	}

	ImageGLCanvas *pCanvas = NULL;
#if USE_OPENGL
	wxFrame *frame = new wxFrame;
	if (opts.bCreateDerivedImages && opts.bUseTextureCompression && opts.eCompressionType == TC_OPENGL)
	{
		frame->Create(g_bld->m_pParentWindow, -1, _T("Texture Compression OpenGL Context"),
			wxPoint(100,400), wxSize(280, 300), wxCAPTION | wxCLIP_CHILDREN);
		pCanvas = new ImageGLCanvas(frame);
	}
#endif

	// make a note of which lods exist
	LODMap lod_existence_map(opts.cols, opts.rows);

	bool bFloat = m_pGrid->IsFloatMode();
	bool bJPEG = (opts.bUseTextureCompression && opts.eCompressionType == TC_JPEG);

	int i, j, lod;
	int total = opts.rows * opts.cols, done = 0;
	for (j = 0; j < opts.rows; j++)
	{
		for (i = 0; i < opts.cols; i++)
		{
			// We might want to skip certain tiles
			if (opts.iMinRow != -1 &&
				(i < opts.iMinCol || i > opts.iMaxCol ||
				 j < opts.iMinRow || j > opts.iMaxRow))
				continue;

			DRECT tile_area;
			tile_area.left = area.left + tile_dim.x * i;
			tile_area.right = area.left + tile_dim.x * (i+1);
			tile_area.bottom = area.bottom + tile_dim.y * j;
			tile_area.top = area.bottom + tile_dim.y * (j+1);

			int col = i;
			int row = opts.rows-1-j;

			// draw our progress in the main view
			if (pView)
//.........这里部分代码省略.........
开发者ID:kamalsirsa,项目名称:vtp,代码行数:101,代码来源:ElevLayer.cpp


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