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


C++ T2类代码示例

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


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

示例1: import_image_data

inline int import_image_data(T2 const& image,
                             WebPPicture & pic,
                             bool alpha)
{
    // Reason for copy: https://github.com/mapnik/mapnik/issues/2024
    // TODO - figure out way to pass view pixels directly to webp importer
    image_data_32 im(image.width(),image.height());
    for (unsigned y = 0; y < image.height(); ++y)
    {
        typename T2::pixel_type const * row_from = image.getRow(y);
        image_data_32::pixel_type * row_to = im.getRow(y);
        for (unsigned x = 0; x < image.width(); ++x)
        {
            row_to[x] = row_from[x];
        }
    }
    int stride = sizeof(typename T2::pixel_type) * im.width();
    if (alpha)
    {
        return WebPPictureImportRGBA(&pic, im.getBytes(), stride);
    }
    else
    {
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
        return WebPPictureImportRGBX(&pic, im.getBytes(), stride);
#else
        return WebPPictureImportRGBA(&pic, im.getBytes(), stride);
#endif
    }
}
开发者ID:tyoc213-watch,项目名称:mapnik,代码行数:30,代码来源:webp_io.hpp

示例2: cmpconv

T cmpconv( const T2 &in) {
#pragma HLS inline
	T2 valIn = in;
	T val(valIn.real(), valIn.imag());
return val;

}
开发者ID:peachypakorn,项目名称:SeniorProjectSrc,代码行数:7,代码来源:nufft_main.cpp

示例3: UpdateItem

void UpdateItem(WORD32 dwKey, T2 &vec, T1 *pData)
{
	T1 *pInfo = NULL;
	SNMP_PERF_VEC_IT it;
	for(it = vec.begin(); it != vec.end(); it++)
	{
		if((*it).dwKey == dwKey)
		{
			pInfo = &(*it);
			check_paranullpt(pInfo);
			memset(pInfo, 0, sizeof(*pInfo));
			memcpy(pInfo, pData, sizeof(*pInfo));
			printf("updateitem, update data, key:%#x\n", dwKey);
			return;
		}
	}
	
	// pInfo = new T1();
	pInfo = &g_snmptest;
	check_paranullpt(pInfo);
	memset(pInfo, 0, sizeof(*pInfo));
	memcpy(pInfo, pData, sizeof(*pInfo));
	vec.push_back(*pInfo);
	printf("updateitem, create data, key:%#x, new addr:%p\n", dwKey, pInfo);

}
开发者ID:weilaidb,项目名称:qtexample,代码行数:26,代码来源:vector_addr.cpp

示例4: composite

void composite(T1 & im, T2 & im2, composite_mode_e mode,
               float opacity,
               int dx,
               int dy,
               bool premultiply_src,
               bool premultiply_dst)
{
    typedef agg::rgba8 color;
    typedef agg::order_rgba order;
    typedef agg::pixel32_type pixel_type;
    typedef agg::comp_op_adaptor_rgba<color, order> blender_type;
    typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_type;
    typedef agg::renderer_base<pixfmt_type> renderer_type;

    agg::rendering_buffer source(im.getBytes(),im.width(),im.height(),im.width() * 4);
    agg::rendering_buffer mask(im2.getBytes(),im2.width(),im2.height(),im2.width() * 4);

    pixfmt_type pixf(source);
    pixf.comp_op(static_cast<agg::comp_op_e>(mode));

    agg::pixfmt_rgba32 pixf_mask(mask);
    if (premultiply_src)  pixf_mask.premultiply();
    if (premultiply_dst)  pixf.premultiply();
    renderer_type ren(pixf);
    // TODO - is this really opacity, or agg::cover?
    ren.blend_from(pixf_mask,0, dx,dy,unsigned(255*opacity));
}
开发者ID:milkbread,项目名称:mapnik,代码行数:27,代码来源:image_compositing.cpp

示例5: isIntersecting

template<class T1, class T2> bool isIntersecting(T1& mA, T2& mB)
{
	return mA.right() >= mB.left() && 
			mA.left() <= mB.right() &&
			mA.bottom() >= mB.top() && 
			mA.top() <= mB.bottom();
}
开发者ID:ardraeiss,项目名称:Tutorials,代码行数:7,代码来源:p7.cpp

示例6: add

	void add(T1 from, T2 to, Lambda lambda) {
		if (from.empty() || to.empty())
			return;
		size_t iFrom = rand() % from.size();
		size_t iTo = rand() % to.size();
		lambda(iFrom, iTo);
	}
开发者ID:dima-murzin,项目名称:Seminars,代码行数:7,代码来源:main.cpp

示例7: Find

  ConstIterator Find(const T2& value)const
  {
	  uint32_t hashCode=value.getHashCode();
	  uint32_t hidx = hashCode%hashSize;

	  Node*const* nodePtr=&hash[hidx];
	  if(!*nodePtr)
		  return ConstIterator(0);

	  if(value.IsSameState(*((*nodePtr)->m_UserState)))
	  {
		  return ConstIterator(this,hidx,*nodePtr,nodePtr);
	  }
	  Node*const* parentPtr=nodePtr;
	  Node* node=(Node*)(*nodePtr)->ihsNextNode;
	  while(node)
	  {
		  if(value.IsSameState(*(node->m_UserState)))
		  {
			  return ConstIterator(this,hidx,node,parentPtr);
		  }
		  parentPtr=nodePtr;
		  nodePtr=(Node**)&node->ihsNextNode;
		  node=(Node*)node->ihsNextNode;
	  }
	  return ConstIterator(0);
  }
开发者ID:QC-git,项目名称:MyLab,代码行数:27,代码来源:IntrHashSet.hpp

示例8: compress

        static bool compress( T2 &buffer_out, const T1 &buffer_in, bool highest_compression = true )
        {
            static const bool verbose = false;

            bool ret = false;

            if( 1 )
            {
                // resize to worst case
                buffer_out.resize( LZ4_compressBound((int)(buffer_in.size())) );

                // compress
                size_t compressed_size = highest_compression ?
                    LZ4_compressHC( &buffer_in.at(0), &buffer_out.at(0), buffer_in.size() )
                    :
                    LZ4_compress( &buffer_in.at(0), &buffer_out.at(0), buffer_in.size() );

                ret = ( compressed_size > 0 && compressed_size < buffer_in.size() );

                if( ret )
                {
                    // if ok, resize properly to unused space
                    buffer_out.resize( compressed_size );
                }

                if( verbose )
                {
//                    std::cout << moon9::echo( ret, compressed_size, buffer_in.size() );
                }
            }

            return ret;
        }
开发者ID:shammellee,项目名称:moon9,代码行数:33,代码来源:compress.hpp

示例9: isIntersecting

 static bool isIntersecting(const T1& mA, const T2& mB) noexcept
 {
     return mA.right()  >= mB.left() 
         && mA.left()   <= mB.right()
         && mA.bottom() >= mB.top() 
         && mA.top()    <= mB.bottom();
 }
开发者ID:fmenozzi,项目名称:games,代码行数:7,代码来源:CollisionManager.hpp

示例10: SokalSimilarity

double SokalSimilarity(const T1& bv1, const T2& bv2) {
  if (bv1.getNumBits() != bv2.getNumBits())
    throw ValueErrorException("BitVects must be same length");
  double x = NumOnBitsInCommon(bv1, bv2);
  double y = bv1.getNumOnBits();
  double z = bv2.getNumOnBits();

  return x / (2 * y + 2 * z - 3 * x);
}
开发者ID:DoliathGavid,项目名称:rdkit,代码行数:9,代码来源:BitOps.cpp

示例11: save_as_png8

void save_as_png8(T1 & file, T2 const& image, T3 const & tree,
                  std::vector<mapnik::rgb> const& palette, std::vector<unsigned> const& alphaTable,
                  int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY)
{
    unsigned width = image.width();
    unsigned height = image.height();

    if (palette.size() > 16 )
    {
        // >16 && <=256 colors -> write 8-bit color depth
        image_data_8 reduced_image(width, height);

        for (unsigned y = 0; y < height; ++y)
        {
            mapnik::image_data_32::pixel_type const * row = image.getRow(y);
            mapnik::image_data_8::pixel_type  * row_out = reduced_image.getRow(y);

            for (unsigned x = 0; x < width; ++x)
            {
                row_out[x] = tree.quantize(row[x]);
            }
        }
        save_as_png(file, palette, reduced_image, width, height, 8, compression, strategy, alphaTable);
    }
    else if (palette.size() == 1)
    {
        // 1 color image ->  write 1-bit color depth PNG
        unsigned image_width  = width > 7 ? (int(0.125*width) + 1)&~1 : 1;
        unsigned image_height = height;
        image_data_8 reduced_image(image_width, image_height);
        reduced_image.set(0);
        save_as_png(file, palette, reduced_image, width, height, 1, compression, strategy, alphaTable);
    }
    else
    {
        // <=16 colors -> write 4-bit color depth PNG
        unsigned image_width  = width > 3 ? (int(0.5*width) + 3)&~3 : 4;
        unsigned image_height = height;
        image_data_8 reduced_image(image_width, image_height);
        for (unsigned y = 0; y < height; ++y)
        {
            mapnik::image_data_32::pixel_type const * row = image.getRow(y);
            mapnik::image_data_8::pixel_type  * row_out = reduced_image.getRow(y);
            byte index = 0;

            for (unsigned x = 0; x < width; ++x)
            {

                index = tree.quantize(row[x]);
                if (x%2 == 0) index = index<<4;
                row_out[x>>1] |= index;
            }
        }
        save_as_png(file, palette, reduced_image, width, height, 4, compression, strategy, alphaTable);
    }
}
开发者ID:doubleotoo,项目名称:mapnik,代码行数:56,代码来源:png_io.hpp

示例12: OffBitProjSimilarity

DoubleVect OffBitProjSimilarity(const T1& bv1, const T2& bv2) {
  if (bv1.getNumBits() != bv2.getNumBits())
    throw ValueErrorException("BitVects must be same length");
  DoubleVect res(2, 0.0);
  double num = (bv1 | bv2).getNumOffBits();
  if (num) {
    res[0] = num / bv1.getNumOffBits();
    res[1] = num / bv2.getNumOffBits();
  }
  return res;
}
开发者ID:DoliathGavid,项目名称:rdkit,代码行数:11,代码来源:BitOps.cpp

示例13: TanimotoSimilarity

double TanimotoSimilarity(const T1& bv1, const T2& bv2) {
  if (bv1.getNumBits() != bv2.getNumBits())
    throw ValueErrorException("BitVects must be same length");
  double x = NumOnBitsInCommon(bv1, bv2);
  double y = bv1.getNumOnBits();
  double z = bv2.getNumOnBits();
  if ((y + z - x) == 0.0)
    return 1.0;
  else
    return x / (y + z - x);
}
开发者ID:DoliathGavid,项目名称:rdkit,代码行数:11,代码来源:BitOps.cpp

示例14: save_as_jpeg

   void save_as_jpeg(T1 & file,int quality, T2 const& image)
   {  
      struct jpeg_compress_struct cinfo;
      struct jpeg_error_mgr jerr;

      int width=image.width();
      int height=image.height();
	
      cinfo.err = jpeg_std_error(&jerr);
      jpeg_create_compress(&cinfo);
    
      cinfo.dest = (struct jpeg_destination_mgr *)(*cinfo.mem->alloc_small)
         ((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof(dest_mgr));
      dest_mgr * dest = (dest_mgr*) cinfo.dest;
      dest->pub.init_destination = init_destination;
      dest->pub.empty_output_buffer = empty_output_buffer;
      dest->pub.term_destination = term_destination;
      dest->out = &file;
      
      //jpeg_stdio_dest(&cinfo, fp);
      cinfo.image_width = width;
      cinfo.image_height = height;
      cinfo.input_components = 3;
      cinfo.in_color_space = JCS_RGB; 
      jpeg_set_defaults(&cinfo);
      jpeg_set_quality(&cinfo, quality,1);
      jpeg_start_compress(&cinfo, 1);
      JSAMPROW row_pointer[1];
      JSAMPLE* row=reinterpret_cast<JSAMPLE*>( ::operator new (sizeof(JSAMPLE) * width*3));
      while (cinfo.next_scanline < cinfo.image_height) 
      {
         const unsigned* imageRow=image.getRow(cinfo.next_scanline);
         int index=0;
         for (int i=0;i<width;++i)
         {
#ifdef MAPNIK_BIG_ENDIAN
            row[index++]=(imageRow[i]>>24)&0xff;
            row[index++]=(imageRow[i]>>16)&0xff;
            row[index++]=(imageRow[i]>>8)&0xff;
#else
            row[index++]=(imageRow[i])&0xff;
            row[index++]=(imageRow[i]>>8)&0xff;
            row[index++]=(imageRow[i]>>16)&0xff;
#endif
         }
         row_pointer[0] = &row[0];
         (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
      }
      ::operator delete(row);
      
      jpeg_finish_compress(&cinfo);
      jpeg_destroy_compress(&cinfo);
   }  
开发者ID:craton-,项目名称:php_mapnik,代码行数:53,代码来源:jpeg_io.hpp

示例15: check_multiplicable

 inline bool check_multiplicable(const char* function,
                                 const char* name1,
                                 const T1& y1,
                                 const char* name2,
                                 const T2& y2) {
   check_positive_size(function, name1, "rows()", y1.rows());
   check_positive_size(function, name2, "cols()", y2.cols());
   check_size_match(function,
                    "Columns of ", name1, y1.cols(),
                    "Rows of ", name2, y2.rows());
   check_positive_size(function, name1, "cols()", y1.cols());
   return true;
 }
开发者ID:javaosos,项目名称:stan,代码行数:13,代码来源:check_multiplicable.hpp


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