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


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

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


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

示例1: InitImage

void InitImage(int minX, int maxX, int minY, int maxY, int mpiRank, 
               Image &img, bool randomSizedImage)
{
  int dimsX = maxX - minX;
  int dimsY = maxY - minY;
  // random image dimension
  int rminX = minX + rand() % (dimsX-1);
  int rminY = minY + rand() % (dimsY-1);
  int rmaxX = rminX + 1 + rand() % (maxX - (rminX+1));
  int rmaxY = rminY + 1 + rand() % (maxY - (rminY+1));
  // random image 
  float depth = (rand() % 100)/100.0;
  // random color
  Color color;
  color.r = (rand() % 256)/256.0;
  color.g = (rand() % 256)/256.0;
  color.b = (rand() % 256)/256.0;
  color.a = (rand() % 256)/256.0;
  // create image
  Timer clock;
  clock.Start();
  if (randomSizedImage) { // random sized images    
    img.CreateImage(rminX, rmaxX, rminY, rmaxY);
    img.ColorImage(color);
  }
  else { // full sized images with bounding box    
    img.CreateImage(maxX, maxY, rminX, rmaxX, rminY, rmaxY);
    img.ColorImage(color, rminX, rmaxX, rminY, rmaxY);
  }
  img.SetDepth(depth);
  clock.Stop();
}
开发者ID:wilsonCernWq,项目名称:QCT,代码行数:32,代码来源:main.cpp

示例2: BuildTileMipMap

	//------------------------------------------------------------------------------------
	// Building the mipmap for a tile based image
	//------------------------------------------------------------------------------------
	bool Image::BuildTileMipMap( int NumCols, int NumRows )
	{
		BuildMipMaps();

		int tW			= m_iWidth  / NumCols;
		int tH			= m_iHeight / NumRows;
		int mipmapLevel = 1;
		int maxmipmaplevel = 0;
		u8* pTempData	= KGE_NEW_ARRAY(u8, tW * tH * 4);
		int t = 1, tth, ttw;

		Image* imgTemp = KGE_NEW(Image)("Temp");
		imgTemp->CreateImage(tW, tH, 1, 4, EIF_RGBA, 0);

		int wi = m_iWidth;
		while (wi > NumCols)
		{
			wi /= 2;
			maxmipmaplevel++;
		}

		io::Logger::Log(io::ELM_Warning, "mmm = %d", maxmipmaplevel);

		for ( int j = 0; j < maxmipmaplevel - 1; j++)
		{
			for (int y = 0; y < NumRows; y++)
			{
				for (int x = 0; x < NumCols; x++)
				{
					GetPixels(x * tW , y * tH, 1, tW, tH, 1, EIF_BGRA, pTempData);
					imgTemp->SetData(pTempData);
					t = math::pow(2, mipmapLevel);
					ttw = tW / t;
					tth = tH / t;
					imgTemp->Scale(ttw, tth, 1);
					SetPixels(x * ttw, y * tth, 1, ttw, tth, 1, EIF_BGRA,
						imgTemp->GetData(), mipmapLevel);

				} // for x

			} // for y

			mipmapLevel++;

		} // for j

		// TODO: Not tested
		KGE_DELETE_ARRAY(pTempData);
		KGE_DELETE(imgTemp, Image);

		return true;

	} // BuildTileMipMap
开发者ID:183amir,项目名称:kge,代码行数:56,代码来源:Imagegfx.cpp

示例3: main

int main(int argc, char **argv) 
{
    Image image;
    
    if(image.Load("calculon640.jpg"))
    {
        /*
        for(unsigned int i = 0; i < image.mDataSize; i+= 3)
        {
            image.mpImage[i+1] = 0;
            image.mpImage[i+2] = 0;
        }
        */
        /*
        unsigned char* buffer = new unsigned char[6000];
        unsigned int len = 6000;
        unsigned int clen = 6000;
        double startTimeS = CxUtils::Timer::GetTimeSeconds();
        for(unsigned int i = 0; i < 100; i++)
        {
            image.Compress(&buffer, &len, &clen, Image::JPEG);
        }
        double finishTimeS = CxUtils::Timer::GetTimeSeconds();
        std::cout << "FPS: " << 100/(finishTimeS - startTimeS) << std::endl;
        */
        //unsigned char* buffer = NULL;
        //unsigned int bufferSize = 0;
        //unsigned int compressSize = 0;
        //image.Compress(&buffer, &bufferSize, &compressSize, Image::JPEG);
        //image.Decompress(buffer, compressSize, Image::JPEG);
        if(image.Save("calculon640_copy.jpg") && image.Save("calculon640_copy.png"))
        {
            cout << "Saved a copy of the image as a JPEG and PNG!\n";
        }

        Image tile;
        tile.CreateImage(image.mWidth, image.mHeight, image.mChannels, image.mpImage, 320, 240, true, true);
        image.ApplyTile(tile);
        image.Save("tile.jpg");
    }

    return 0;
}
开发者ID:jarekAIM,项目名称:IGVC2015,代码行数:43,代码来源:ExampleImages.cpp


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