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


C++ Image::DataType方法代码示例

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


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

示例1: MulAndScaleSpectrums

void ImageProximityFFT::MulAndScaleSpectrums(Image& Source, Image& Template, Image& Dest, float scale)
{
   CheckSameSize(Source, Template);
   CheckSameSize(Source, Dest);

   // Verify image types
   if (Source.DataType() != SImage::F32 || Template.DataType() != SImage::F32 || Dest.DataType() != SImage::F32)
      throw cl::Error(CL_IMAGE_FORMAT_NOT_SUPPORTED, "The function works only with F32 images");

   // Verify image types
   if (Source.NbChannels() != 2 || Template.NbChannels() != 2 || Dest.NbChannels() != 2)
      throw cl::Error(CL_IMAGE_FORMAT_NOT_SUPPORTED, "The function works only with 2 channel images");

   Kernel(mulAndScaleSpectrums, Source, Template, Dest, Source.Step(), Template.Step(), Dest.Step(), Source.Width(), Source.Height(), scale);
}
开发者ID:AntAgna,项目名称:OpenCLIPP,代码行数:15,代码来源:ImageProximityFFT.cpp

示例2: Update

/*
====================
Update
====================
*/
VOID EChunk::Update()
{
	GUARD(EChunk::Update);

	// erase the layer that is invalid
	std::vector<Layer>::iterator it = mLayers.begin();
	while(it != mLayers.end())
	{
		Layer& layer = (*it);
		if(layer.total==0)
		{
			it = mLayers.erase(it);
		}
		else
		{
			++it;
		}
	}

	// update the alpha texture
	U32 width = U2P(ALPHA_STRIDE);
	U32 height = U2P(ALPHA_STRIDE);
	for(I32 k = 0; k < mLayers.size(); k++)
	{
		Layer& layer = mLayers[k];
		Image* image = GNEW(Image); CHECK(image);
		image->Width(width);
		image->Height(height);
		image->PixelFormat(PF_ALPHA);
		image->DataType(DT_UNSIGNED_BYTE);
		image->MipmapCount(1);
		if(k==0)
		{
			image->Mipmap(0,NULL,width*height*sizeof(U8));
			U8* data = (U8*)image->Mipmap(0);
			for(U32 j = 0; j < height; j++)
			{
				for( U32 i = 0; i < width; i++)
				{
					U8& alpha = layer.alpha[i+j*width];
					U8& mask = mMask[i+j*width];
					if(mask == 0) data[i+j*width] = (U8)(((F32)alpha)/255.0f*127.0f);
					else data[i+j*width] = (U8)(((F32)alpha)/255.0f*127.0f)+128;
				}
			}
			layer.texture->Load(image);
			layer.primitive->SetShader(dynamic_cast<Shader*>(mShaderKey->Ptr()), "base");
		}
		else
		{
			image->Mipmap(0,&layer.alpha[0],width*height*sizeof(U8));
			layer.texture->Load(image);
			layer.primitive->SetShader(dynamic_cast<Shader*>(mShaderKey->Ptr()), "layer");
		}
	}

	UNGUARD;
}
开发者ID:sundoom,项目名称:glare,代码行数:63,代码来源:EChunk.cpp

示例3: Convert

void Conversions::Convert(Image& Source, Image& Dest)
{
   CheckSameSize(Source, Dest);

   if (SameType(Source, Dest))
   {
      Copy(Source, Dest);
      return;
   }

   switch (Dest.DataType())
   {
   case SImage::U8:
      Kernel(to_uchar, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::S8:
      Kernel(to_char, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::U16:
      Kernel(to_ushort, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::S16:
      Kernel(to_short, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::U32:
      Kernel(to_uint, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::S32:
      Kernel(to_int, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::F32:
      Kernel(to_float, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::F64:
      Kernel(to_double, Source, Dest, Source.Step(), Dest.Step());
      break;
   case SImage::NbDataTypes:
   default:
      throw cl::Error(CL_IMAGE_FORMAT_NOT_SUPPORTED, "Unsupported data type");
   }
   
}
开发者ID:CRVI,项目名称:OpenCLIPP,代码行数:42,代码来源:Conversions.cpp

示例4: Scale

void Conversions::Scale(Image& Source, Image& Dest, int Offset, float Ratio)
{
   CheckSameSize(Source, Dest);

   switch (Dest.DataType())
   {
   case SImage::U8:
      Kernel(scale_to_uchar, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::S8:
      Kernel(scale_to_char, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::U16:
      Kernel(scale_to_ushort, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::S16:
      Kernel(scale_to_short, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::U32:
      Kernel(scale_to_uint, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::S32:
      Kernel(scale_to_int, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::F32:
      Kernel(scale_to_float, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::F64:
      Kernel(scale_to_double, Source, Dest, Source.Step(), Dest.Step(), Offset, Ratio);
      break;
   case SImage::NbDataTypes:
   default:
      throw cl::Error(CL_IMAGE_FORMAT_NOT_SUPPORTED, "Unsupported data type");
   }

}
开发者ID:CRVI,项目名称:OpenCLIPP,代码行数:36,代码来源:Conversions.cpp

示例5: build

/*
====================
build
====================
*/
VOID Game::build()
{
    GUARD(Game::build);

    // build the color texture
    Image* image = GNEW(Image);
    CHECK(image);
    image->Width(256);
    image->Height(256);
    image->Depth(1);
    image->PixelFormat(PF_RGBA);
    image->DataType(DT_UNSIGNED_BYTE);
    mColorTexPtr = GNEW(Texture);
    CHECK(mColorTexPtr);
    mColorTexPtr->Load(image);

    // build the color rt
    mColorRTPtr = GNEW(Target(mColorTexPtr.Ptr()));
    CHECK(mColorRTPtr);

    // build the primitive
    mQuadPtr = GNEW(Primitive);
    CHECK(mQuadPtr);
    mQuadPtr->SetType(Primitive::PT_TRIANGLES);

    // set the wvp
    Constant* wvp_constant_ptr = GNEW(Constant);
    CHECK(wvp_constant_ptr);
    wvp_constant_ptr->SetMatrix(Matrix());
    mQuadPtr->SetConstant("gWVP",wvp_constant_ptr);

    // set the color texture
    Constant* texture_constant_ptr = GNEW(Constant);
    CHECK(texture_constant_ptr);
    texture_constant_ptr->SetTexture(mColorTexPtr.Ptr());
    mQuadPtr->SetConstant("gBaseTex",texture_constant_ptr);

    // set the shader
    Str shader_key_name = "shader/default.xml";
    KeyPtr shader_key_ptr = Key::Find(shader_key_name.c_str());
    if(shader_key_ptr == NULL)
    {
        Shader*shader = GNEW(Shader);
        CHECK(shader);
        shader->Load(GLoad(shader_key_name.c_str()));
        shader_key_ptr = GNEW(Key(shader_key_name.c_str(), shader));
        CHECK(shader_key_ptr);
    }
    mKeys.push_back(shader_key_ptr);
    mQuadPtr->SetShader(dynamic_cast<Shader*>(shader_key_ptr->Ptr()),"p0");

    // build the vertex buffer
    F32 x = 0.0f, y = 0.0f, w = 256, h = 256;
    DVT vertexes[] =
    {
        {x,		y,		0,		0,		0},
        {x+w,	y,		0,		1,		0},
        {x+w,	y+h,	0,		1,		1},
        {x,		y+h,	0,		0,		1},
    };
    VertexBufferPtr vb_ptr = GNEW(VertexBuffer);
    CHECK(vb_ptr);
    {
        GDataPtr vd_ptr = GNEW(GData);
        CHECK(vd_ptr);
        vd_ptr->Size(3*sizeof(U32) + 3*sizeof(U8) + sizeof(vertexes));
        U8*data_ptr = (U8*)vd_ptr->Ptr();
        *(U32*)data_ptr = MAKEFOURCC('G','V','B','O');
        data_ptr += sizeof(U32);
        *(U32*)data_ptr = sizeof(vertexes)/sizeof(DVT);
        data_ptr += sizeof(U32);
        *(U32*)data_ptr = sizeof(DVT);
        data_ptr += sizeof(U32);
        *(U8*)data_ptr = 2;
        data_ptr += sizeof(U8);
        *(U8*)data_ptr = VertexBuffer::VT_3F;
        data_ptr += sizeof(U8);
        *(U8*)data_ptr = VertexBuffer::VT_2F;
        data_ptr += sizeof(U8);
        ::memcpy(data_ptr, vertexes, sizeof(vertexes));
        data_ptr += sizeof(vertexes);
        vb_ptr->Load(vd_ptr.Ptr());
    }
    mQuadPtr->SetVertexBuffer(vb_ptr.Ptr());

    // build the index
    const U16 indexes[] = { 3, 0, 2, 2, 0, 1 };
    IndexBufferPtr ib_ptr = GNEW(IndexBuffer);
    CHECK(ib_ptr);
    {
        GDataPtr id_ptr = GNEW(GData);
        CHECK(id_ptr);
        id_ptr->Size(3*sizeof(U32) + sizeof(indexes));
        U8*data_ptr = (U8*)id_ptr->Ptr();
        *(U32*)data_ptr = MAKEFOURCC('G','I','B','O');
//.........这里部分代码省略.........
开发者ID:sundoom,项目名称:sunstudio,代码行数:101,代码来源:Game.cpp

示例6: Find

/*
====================
Find
====================
*/
U32 EChunk::Find(const CHAR* name, const Vector2& st)
{
	GUARD(EChunk::Find);	

	CHECK(name);
	
	// searche the layer table
	for(U32 i = 0; i < mLayers.size(); i++)
	{
		if(mLayers[i].name == name && mLayers[i].st == st) return i;
	}

	// create the new layer
	Layer layer;
	layer.name = name;
	layer.st = st;
	layer.alpha.resize(U2P(ALPHA_STRIDE)*U2P(ALPHA_STRIDE), 0);
	layer.total = 0;

	// create the new primitive
	layer.primitive = GNEW(Primitive); CHECK(layer.primitive);
	layer.primitive->SetType(Primitive::PT_TRIANGLES);
	layer.primitive->SetVertexBuffer(mVBPtr.Ptr());
	layer.primitive->SetIndexBuffer(mIBPtr.Ptr());	
	layer.primitive->SetConstant("gWVP",GNEW(Constant(Matrix())));

	// get the color texture
	KeyPtr texture_key_ptr = Key::Find(name);
	if(texture_key_ptr == NULL)
	{
		const Image* image = Image::Load(GLoad(name)); CHECK(image);
		BaseTexture* base_texture = GNEW(Texture); CHECK(base_texture);
		base_texture->Load(image);
		texture_key_ptr = GNEW(Key(name, base_texture)); CHECK(texture_key_ptr);
	}
	mKeys.push_back(texture_key_ptr);
	layer.primitive->SetConstant("gColorTex",GNEW(Constant((BaseTexture*)texture_key_ptr->Ptr())));

	// set the scale st	
	layer.primitive->SetConstant("gScaleST",GNEW(Constant(Vector4(st[0],st[1],0,0))));	

	// set the alpha
	U32 width = U2P(ALPHA_STRIDE);
	U32 height = U2P(ALPHA_STRIDE);
	Image* image = GNEW(Image); CHECK(image);
	image->Width(width);
	image->Height(height);
	image->PixelFormat(PF_ALPHA);
	image->DataType(DT_UNSIGNED_BYTE);
	image->MipmapCount(1);
	image->Mipmap(0,&layer.alpha[0],width*height*sizeof(U8));		
	BaseTexture *alpha_texture = GNEW(Texture); CHECK(alpha_texture);
	alpha_texture->Load(image);
	layer.primitive->SetConstant("gAlphaTex",GNEW(Constant(alpha_texture)));
	layer.texture = alpha_texture;

	// load the shader
	layer.primitive->SetShader(dynamic_cast<Shader*>(mShaderKey->Ptr()), "layer");
	
	// add the layer to the table
	mLayers.push_back(layer);
	return mLayers.size() - 1;

	UNGUARD;
}
开发者ID:sundoom,项目名称:glare,代码行数:70,代码来源:EChunk.cpp


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