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


C++ CImage::GetFileName方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
  std::vector<std::string> files;

  if(argc < 2)
    return 0;

  GetFiles(std::string(argv[1]), files);

  if(files.size() < 1)
    return 0;

  ilInit();
  iluInit();
  ilEnable( IL_ORIGIN_SET );
  ilOriginFunc( IL_ORIGIN_UPPER_LEFT );
  ilEnable( IL_TYPE_SET );
  ilSetInteger( IL_TYPE_MODE, IL_UNSIGNED_BYTE );

  std::list<CImageTree *> m_imageTree;

  CImageTree *imageTree = new CImageTree(ATLAS_WIDTH, ATLAS_HEIGHT);

  m_imageTree.push_back(imageTree);

  std::vector<CImage *> m_imageList;

  for(std::vector<std::string>::const_iterator ifiles = files.begin(); ifiles != files.end(); ++ifiles )
  {
    std::string file = (*ifiles);

    CImage *image = new CImage(file);

    // no image
    if(image->GetWidth() == 0 || image->GetHeight() == 0)
    {
      delete image;
      continue;
    }

    // add image by size in image list
    bool nAdd = false;
    for(std::vector<CImage *>::iterator iimage = m_imageList.begin(); iimage != m_imageList.end(); ++iimage )
    {
      CImage *image_check = (*iimage);

      if((image->GetWidth() * image->GetHeight()) > (image_check->GetWidth() * image_check->GetHeight()))
      {
        m_imageList.insert(iimage--, image);
        nAdd = true;
        break;
      }
    }

    if(!nAdd)
      m_imageList.push_back(image);
  }

  for(std::vector<CImage *>::const_iterator iimage = m_imageList.begin(); iimage != m_imageList.end(); ++iimage )
  {
    CImage *image = (*iimage);

    // image does not fit in map at all
    if(image->GetWidth() > ATLAS_WIDTH || image->GetHeight() > ATLAS_HEIGHT)
    {
      printf("Image : %s to big\n", image->GetFileName().c_str());
      continue;
    }

    // insert image in map
    for(std::list<CImageTree *>::const_iterator itree = m_imageTree.begin(); itree != m_imageTree.end(); ++itree)
    {
      CImageTree *imageTree = (*itree);
      if(imageTree->Insert(image, 0))
      {
        image = NULL;
        break;
      }
    }

    // start a new map if the image was not added to the existing map's
    if(image != NULL)
    {
      CImageTree *imageTree = new CImageTree(ATLAS_WIDTH, ATLAS_HEIGHT);
      m_imageTree.push_back(imageTree);
      if(!imageTree->Insert(image, 0))
        printf("File : %s does not fit\n", image->GetFileName().c_str());
    }
  }

  int count = 0;
  for( std::list<CImageTree *>::const_iterator itree = m_imageTree.begin(); itree != m_imageTree.end(); ++itree )
  {
    CImageTree *imageTree = (*itree);
    std::stringstream ss;
    ss << count;
    std::string filename = "media-2048-" + ss.str() + ".png";
    imageTree->SaveImage(filename);
    filename = "media-2048-" + ss.str() + ".txt";
    imageTree->SaveIndex(filename);
//.........这里部分代码省略.........
开发者ID:huceke,项目名称:texture-atlas,代码行数:101,代码来源:texture-atlas.cpp


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