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


C++ BitMap类代码示例

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


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

示例1: CreatePlane

void CreatePlane(GameObject& obj, Vector4 worldPos, const char* texture)
{
	Vertex v00, v01, v02, v03;

	v00.normal = Vector4::zero;
	v01.normal = Vector4::zero;
	v02.normal = Vector4::zero;
	v03.normal = Vector4::zero;

	Poly p0, p1;
	BitMap bm;
	if (texture != NULL && bm.Read(texture))
	{
		p0.texture = bm;
		p1.texture = bm;

		v00.uv = Vector2(0.0f, 0.0f);
		v01.uv = Vector2(1.0f, 0.0f);
		v02.uv = Vector2(0.0f, 1.0f);
		v03.uv = Vector2(1.0f, 1.0f);
	}
	else
	{
		v00.color = ColourValue::Gray;
		v01.color = ColourValue::Gray;
		v02.color = ColourValue::Gray;
		v03.color = ColourValue::Gray;
	}

	v00.position = Vector4(1, 1, 1, 1);
	v01.position = Vector4(-1, 1, 1, 1);
	v02.position = Vector4(1, -1, 1, 1);
	v03.position = Vector4(-1, -1, 1, 1);

	obj.vertexListLocal[0] = v00;
	obj.vertexListLocal[1] = v01;
	obj.vertexListLocal[2] = v02;
	obj.vertexListLocal[3] = v03;

	p0.vertices = obj.vertexListTrans;
	p0.vertexIndexs[0] = 0;
	p0.vertexIndexs[1] = 1;
	p0.vertexIndexs[2] = 3;

	p1.vertices = obj.vertexListTrans;
	p1.vertexIndexs[0] = 3;
	p1.vertexIndexs[1] = 2;
	p1.vertexIndexs[2] = 0;

	// 设置物体属性
	obj.polyCount = 2;
	obj.polyList[0] = p0;
	obj.polyList[1] = p1;
	
	obj.vertexCount = 4;
	obj.worldPos = worldPos;

	obj.ComputeVertexNormals();
}
开发者ID:snuc,项目名称:SoftRenderer,代码行数:59,代码来源:SoftRenderer.cpp

示例2:

DisplacementPatchSampler::DisplacementPatchSampler(const GeometryImage & detailedGeometryMap, const BitMap & detailedGeometryMask, GeometryImage & geometryMap, BitMap & geometryMask) :
	m_detailedGeometryMap(detailedGeometryMap), 
	m_detailedGeometryMask(detailedGeometryMask),
	m_geometryMap(geometryMap), 
	m_geometryMask(geometryMask)
{
	nvCheck(geometryMap.width() == geometryMask.width());
	nvCheck(geometryMap.height() == geometryMask.height());
}
开发者ID:DanielGeorge,项目名称:nvidia-mesh-tools,代码行数:9,代码来源:Samplers.cpp

示例3: clear_bits

void BCEscapeAnalyzer::clear_bits(ArgumentMap vars, BitMap &bm) {
  for (int i = 0; i <= _arg_size; i++) {
    if (vars.contains(i)) {
      bm.clear_bit(i);
    }
  }
}
开发者ID:GregBowyer,项目名称:ManagedRuntimeInitiative,代码行数:7,代码来源:bcEscapeAnalyzer.cpp

示例4: b

void OrientedGraph::levelPartition(Partition& pi) const

/*
  Assuming the graph has no oriented cycles, this function writes in pi the 
  partition of the vertices according to their level, where sinks have level
  0, then sinks in the remaining poset have level one, etc.

  NOTE : the implementation is simple-minded : we traverse the graph as many
  times as there are levels.
*/

{
  static BitMap b(0);
  static BitMap b1(0);

  b.setSize(size());
  b.reset();
  b1.setSize(size());
  b1.reset();
  pi.setSize(size());
  Ulong count = 0;
  Ulong current_level = 0;

  while (count < size()) {
    for (SetElt x = 0; x < size(); ++x) {
      if (b.getBit(x))
	continue;
      const EdgeList e = d_edge[x];
      for (Ulong j = 0; j < e.size(); ++j) {
	if (!b.getBit(e[j])) /* next x */
	  goto nextx;
      }
      /* i we get here, x is the next element in the permutation */
      pi[x] = current_level;
      b1.setBit(x);
      ++count;
    nextx:
      continue;
    }
    b.assign(b1);
    current_level++;
  }

  pi.setClassCount(current_level);
  return;
}
开发者ID:tscrim,项目名称:coxeter,代码行数:46,代码来源:wgraph.cpp

示例5:

BloomFilter::BloomFilter(size_t N, size_t K, const BitMap &bits)
   : N_(N),
     M_(bits.size()),
     K_(K),
     bits_(bits),
     pFalse_(computePFalse(N, M_, K)) 
{
}
开发者ID:cDoru,项目名称:ebn-sddr,代码行数:8,代码来源:BloomFilter.cpp

示例6: _orgWidth

Texture::Texture(const BitMap& bitmap, GLint minMagFilter,GLint wrapMode): _orgWidth((GLfloat)bitmap.width()), _orgHeight((GLfloat)bitmap.height()){
	glGenTextures(1, &_object);
	glBindTexture(GL_TEXTURE_2D, _object);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,minMagFilter);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,minMagFilter);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,wrapMode);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,wrapMode);
	glTexImage2D(GL_TEXTURE_2D, 0,
		textureFormatforBitmap(bitmap.format(),true), 
		(GLsizei)bitmap.width(), 
		(GLsizei)bitmap.height(), 
		0,
		textureFormatforBitmap(bitmap.format(),false), 
		GL_UNSIGNED_BYTE,
		bitmap.pixelBuffer());
	glGenerateMipmap(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,0);

}
开发者ID:Dakini,项目名称:OpenGL-SSAO,代码行数:19,代码来源:texture.cpp

示例7: merge_cleanup_fpu_stack

void FpuStackAllocator::merge_cleanup_fpu_stack(LIR_List* instrs, FpuStackSim* cur_sim, BitMap& live_fpu_regs) {
#ifndef PRODUCT
  if (TraceFPUStack) {
    tty->cr();
    tty->print("before cleanup: state: "); cur_sim->print(); tty->cr();
    tty->print("                live:  "); live_fpu_regs.print_on(tty); tty->cr();
  }
#endif

  int slot = 0;
  while (slot < cur_sim->stack_size()) {
    int reg = cur_sim->get_slot(slot);
    if (!live_fpu_regs.at(reg)) {
      if (slot != 0) {
        merge_insert_xchg(instrs, cur_sim, slot);
      }
      merge_insert_pop(instrs, cur_sim);
    } else {
      slot++;
    }
  }

#ifndef PRODUCT
  if (TraceFPUStack) {
    tty->print("after cleanup:  state: "); cur_sim->print(); tty->cr();
    tty->print("                live:  "); live_fpu_regs.print_on(tty); tty->cr();
    tty->cr();
  }

  // check if fpu stack only contains live registers
  for (unsigned int i = 0; i < live_fpu_regs.size(); i++) {
    if (live_fpu_regs.at(i) != cur_sim->contains(i)) {
      tty->print_cr("mismatch between required and actual stack content");
      break;
    }
  }
#endif
}
开发者ID:lmsf,项目名称:jdk9-dev,代码行数:38,代码来源:c1_LinearScan_x86.cpp

示例8: a

void OrientedGraph::permute(const Permutation& a)

/*
  This function permutes the graph according to the permutation a, according
  to the usual rule : the edges of a(x) should be the image under a of the
  edge set of x.

  As usual, permuting values is easy : it is enough to apply a to the
  elements in the various edgelists. Permuting ranges is trickier, because
  it involves a^-1.

  It is assumed of course that a holds a permutation of size size().
*/

{
  static BitMap b(0);
  static EdgeList e_buf(0);

  /* permute values */

  for (SetElt x = 0; x < size(); ++x) {
    EdgeList& e = d_edge[x];
    for (Ulong j = 0; j < e.size(); ++j) {
      e[j] = a[e[j]];
    }
  }

  /* permute ranges */

  b.setSize(size());
  b.reset();

  for (SetElt x = 0; x < size(); ++x) {
    if (b.getBit(x))
      continue;
    if (a[x] == x) { /* fixed point */
      b.setBit(x);
      continue;
    }
    for (SetElt y = a[x]; y != x; y = a[y]) {
      /* back up values for y */
      e_buf.shallowCopy(d_edge[y]);
      /* put values for x in y */
      d_edge[y].shallowCopy(d_edge[x]);
      /* store backup values in x */
      d_edge[x].shallowCopy(e_buf);
      /* set bit */
      b.setBit(y);
    }
    b.setBit(x);
  }
}
开发者ID:tscrim,项目名称:coxeter,代码行数:52,代码来源:wgraph.cpp

示例9: savePicAsHeightMap

void savePicAsHeightMap( std::string const& infile, std::string const& outfile ) {

	ImageIO::init();

	BitMap*	in	= ImageIO::load( infile );
	BitMap* out	= new BitMap( in->getWidth(), in->getHeight() );

	for( int j=0; j<in->getHeight(); j++ ) {
		for( int i=0; i<in->getWidth(); i++ ) {
			unsigned int col = in->get( i, j );
			int r = ( col >> 16 ) & 0xff;
			int g = ( col >> 8 ) & 0xff;
			int b = col & 0xff;
			int v = (int)( (double)r * 0.2125 + (double)g * 0.7154 + (double)b * 0.0721 ) & 0xff;
			out->set( i, j, ( 0xff << 24 ) | ( v << 16 ) | ( v << 8 ) | v );
		}
	}

	ImageIO::save( outfile, *out );

	delete out;
	delete in;
}
开发者ID:mgnauck,项目名称:miko-raytracer,代码行数:23,代码来源:_trash.cpp

示例10: save

bool BMP::save( std::string const& filename, BitMap const& map ) {

	FILE*	f	= fopen( filename.c_str(), "wb" );

	assert( f );

	int	width	= map.getWidth();
	int	height	= map.getHeight();

	// bitmap file header
	unsigned short	bfType			= 0x4D42;								// "BM"
	unsigned int	bfSize			= 54 + width * height * 3;
	unsigned short	bfReserved1		= 0;
	unsigned short	bfReserved2		= 0;
	unsigned int	bfOffbits		= 54;
	
	fwrite( &bfType, 2, 1, f );
	fwrite( &bfSize, 4, 1, f );
	fwrite( &bfReserved1, 2, 1, f );
	fwrite( &bfReserved2, 2, 1, f );
	fwrite( &bfOffbits, 4, 1, f );

	// bitmap info header
    unsigned int	biSize			= 40;							// bmih size
    int				biWidth			= width;
    int				biHeight		= height;
    unsigned short	biPlanes		= 1;
    unsigned short	biBitCount		= 24;							// RGB
    unsigned int	biCompression	= 0;							// type: RGB
    unsigned int	biSizeImage		= width * height * 3;
    int				biXPelsPerMeter	= 2925;
    int				biYPelsPerMeter	= 2925;
    unsigned int	biClrUsed		= 0;
    unsigned int	biClrImportant	= 0;

	fwrite( &biSize, 4, 1, f );
	fwrite( &biWidth, 4, 1, f );
	fwrite( &biHeight, 4, 1, f );
	fwrite( &biPlanes, 2, 1, f );
	fwrite( &biBitCount, 2, 1, f );
	fwrite( &biCompression, 4, 1, f );
	fwrite( &biSizeImage, 4, 1, f );
	fwrite( &biXPelsPerMeter, 4, 1, f );
	fwrite( &biYPelsPerMeter, 4, 1, f );
	fwrite( &biClrUsed, 4, 1, f );
	fwrite( &biClrImportant, 4, 1, f );

	// write data
	for( int j=0; j<height; j++ ) {

		for( int i=0; i<width; i++ ) {

			unsigned int	c	= map.get( i, height - j - 1 );

			unsigned char	b	= ( c >> 16 ) & 0xff;
			unsigned char	g	= ( c >> 8 ) & 0xff;
			unsigned char	r	= c & 0xff;

			fwrite( &b, 1, 1, f );
			fwrite( &g, 1, 1, f );
			fwrite( &r, 1, 1, f );
		}
	}

	fclose( f );

	return true;
}
开发者ID:mgnauck,项目名称:miko-raytracer,代码行数:68,代码来源:BMP.cpp

示例11: while

RC RM_FileScan::GetNextRec(RM_Record &rec) {
    if (!bInScan)
        return RM_ERR_NOTINSCAN;
    RC rc;
    RID rid;
    RM_Record tmpRec;
    while (1) {
        //std::cout <<"start next : "<< nowPage <<" "<<nowSlot<<"\n";
        if (bNextPage) {
            //std::cout << "before next page:" << nowPage<<"\n";
            if (PF_ERR_EOF == fileHandle.pfh.GetNextPage(nowPage, nowPH)) {
                bInScan = false;
                return RM_ERR_EOF;
            }
            if (rc = nowPH.GetPageNum(nowPage)) 
                return rc;
            //std::cout << "after next page:" << nowPage<<"\n";
            bNextPage = false;
            nowSlot = -1;
            continue;
        }  

        char *pData;
        if (rc = nowPH.GetData(pData))
            return rc;
        BitMap bitmap;
        if (rc = fileHandle.GetBitMapFromData(pData, bitmap))
            return rc;
        //bitmap.print();
        int nextBit;
        if (RM_ENDOFPAGE == bitmap.GetNextBit(nowSlot, nextBit)) {
            if (rc = fileHandle.pfh.UnpinPage(nowPage))
                return rc;
            bNextPage = true;
            continue;
        }  
        //std::cout << "nextbit: " << nextBit <<"\n";


        nowSlot = nextBit;
        RID rid;
        rid.SetPageNum(nowPage);
        rid.SetSlotNum(nowSlot);

//        std::cout << "find slot: pageNum:"<<nowPage<<"    slotNum:"<<nowSlot<<"\n";

        //std::cout << "recordSize:" << fileHandle.header.recordSize<<"\n";
        //std::cout << "firstFree :" << fileHandle.header.firstFree <<"\n";
        //std::cout << "bitmapOffset :" << fileHandle.header.bitmapOffset <<"\n";
        //std::cout << "bitmapSize : " << fileHandle.header.bitmapSize <<"\n";
        //std::cout << "numRecordsPerPage : " << fileHandle.header.numRecordsPerPage <<"\n";
        //std::cout << "numPages : " << fileHandle.header.numPages <<"\n";
        //std::cout << rid.pageNum <<" "<<rid.slotNum<<"\n";


        if (rc = fileHandle.GetRecordFromData(pData, rid, tmpRec))
            return rc;

        //for (int i = 0; i < fileHandle.header.recordSize; i++) 
        //    std::cout << (int)tmpRec.pData[i] <<" ";
        //std::cout <<"\n";
        
        //std::cout << "recdata: " << (int)tmpRec.pData[3]<<"\n";
        //std::cout << "offset:"<<attrOffset<<" "<<"    len:"<<attrLength<<"  type:"<<attrType<<"\n";
        //std::cout << "compop:"<<this->compOp<<"\n";
        
        char *tmpRecData;
        if (rc = tmpRec.GetData(tmpRecData))
            return rc;
        

        if (this->compOp != NO_OP) {
            bool flag;
            if (this->compOp != IS_OP && this->compOp != IS_NOT_OP && tmpRec.IsNull(attrNumber)) 
                flag = false;
            else
                flag = (* cmp)(tmpRecData + attrOffset, this->value, attrType, attrLength);

            if (flag) { 
                rec = tmpRec;
                break;
            }
        }  else {
            rec = tmpRec; 
            break;
        }
    }
    return 0;
}
开发者ID:VincentX2016,项目名称:NaiveSQL,代码行数:89,代码来源:RM_FileScan.cpp

示例12: fopen

BitMap* BMP::load( std::string const& filename ) {

	FILE*	f	= fopen( filename.c_str(), "rb" );

	assert( f );

	// bitmap file header
	unsigned short	bfType;
	unsigned int	bfSize;
	unsigned short	bfReserved1;
	unsigned short	bfReserved2;
	unsigned int	bfOffbits;

	fread( &bfType, 2, 1, f );
	fread( &bfSize, 4, 1, f );
	fread( &bfReserved1, 2, 1, f );
	fread( &bfReserved2, 2, 1, f );
	fread( &bfOffbits, 4, 1, f );

	// bitmap info header
    unsigned int	biSize;
    int				biWidth;
    int				biHeight;
    unsigned short	biPlanes;
    unsigned short	biBitCount;
    unsigned int	biCompression;
    unsigned int	biSizeImage;
    int				biXPelsPerMeter;
    int				biYPelsPerMeter;
    unsigned int	biClrUsed;
    unsigned int	biClrImportant;

	fread( &biSize, 4, 1, f );
	fread( &biWidth, 4, 1, f );
	fread( &biHeight, 4, 1, f );
	fread( &biPlanes, 2, 1, f );
	fread( &biBitCount, 2, 1, f );
	fread( &biCompression, 4, 1, f );
	fread( &biSizeImage, 4, 1, f );
	fread( &biXPelsPerMeter, 4, 1, f );
	fread( &biYPelsPerMeter, 4, 1, f );
	fread( &biClrUsed, 4, 1, f );
	fread( &biClrImportant, 4, 1, f );

	BitMap* m = new BitMap( biWidth, biHeight );

	// read data
	for( int j=0; j<biHeight; j++ ) {

		for( int i=0; i<biWidth; i++ ) {

			unsigned char	a, r, g, b;

			fread( &b, 1, 1, f );
			fread( &g, 1, 1, f );
			fread( &r, 1, 1, f );

			if( biBitCount == 32 )
				fread( &a, 1, 1, f );	
			else if( biBitCount == 24 )
				a = 0xff;

			m->set( i, biHeight - j - 1, ( a << 24 ) | ( b << 16 ) | ( g << 8 ) | r );
		}
	}

	fclose( f );

	return m;
}
开发者ID:mgnauck,项目名称:miko-raytracer,代码行数:70,代码来源:BMP.cpp

示例13: is_obj_beg

inline bool ParMarkBitMap::is_obj_beg(idx_t bit) const
{
  return _beg_bits.at(bit);
}
开发者ID:guanxiaohua,项目名称:TransGC,代码行数:4,代码来源:parMarkBitMap.hpp

示例14: is_obj_end

inline bool ParMarkBitMap::is_obj_end(idx_t bit) const
{
  return _end_bits.at(bit);
}
开发者ID:guanxiaohua,项目名称:TransGC,代码行数:4,代码来源:parMarkBitMap.hpp

示例15: clear_range

inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end)
{
  _beg_bits.clear_range(beg, end);
  _end_bits.clear_range(beg, end);
}
开发者ID:guanxiaohua,项目名称:TransGC,代码行数:5,代码来源:parMarkBitMap.hpp


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