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


C++ CImagePtr::getWidth方法代码示例

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


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

示例1: exit

extern void
setRootImage(CImagePtr &image)
{
  Pixel bg = CXMachineInst->getBlackPixel();
  Pixel fg = CXMachineInst->getWhitePixel();

  GC gc = CXMachineInst->createGC(fg, bg);

  int w = CXMachineInst->getWidth ();
  int h = CXMachineInst->getHeight();

  Pixmap pixmap = CXMachineInst->createXPixmap(w, h);

  CXMachineInst->fillRectangle(pixmap, gc, 0, 0, w, h);

  CXImage *cximage = image.cast<CXImage>();

  if (cximage == NULL)
    exit(1);

  XImage *ximage = cximage->getXImage();

  int iw = image->getWidth ();
  int ih = image->getHeight();

  if (iw > w) w = iw;
  if (ih > h) h = ih;

  int dst_x = (w - iw)/2;
  int dst_y = (h - ih)/2;

  Window root = CXMachineInst->getRoot();

  CXMachineInst->putImage(pixmap, gc, ximage, 0, 0,
                          dst_x, dst_y, (uint) iw, (uint) ih);
  CXMachineInst->putImage(root  , gc, ximage, 0, 0,
                          dst_x, dst_y, (uint) iw, (uint) ih);

  CXMachineInst->setWindowBackgroundPixmap(root, pixmap);

  CXMachineInst->freeGC(gc);

  CXMachineInst->freeXPixmap(pixmap);

  CXMachineInst->clearWindow(root);

  CXMachineInst->flushEvents();

  const CXAtom &atom = CXMachineInst->getXSetRootIdAtom();

  Pixmap pixmap1;

  if (CXMachineInst->getPixmapProperty(root, atom, &pixmap1)) // delete ?
    CXMachineInst->killClient(pixmap1);

  CXMachineInst->deleteProperty(root, atom);

  CXMachineInst->flushEvents();
}
开发者ID:colinw7,项目名称:CXLib,代码行数:59,代码来源:CXRootImage.cpp

示例2: if

int
main(int argc, char **argv)
{
  bool        flip_dir = false;
  const char *format   = "_%d_%d";

  char *filename = 0;
  char *dx_str   = 0;
  char *dy_str   = 0;
  char *sx_str   = 0;
  char *sy_str   = 0;

  for (int i = 1; i < argc; ++i) {
    if (argv[i][0] == '-') {
      if      (strcmp(&argv[i][1], "flip_dir") == 0)
        flip_dir = true;
      else if (strcmp(&argv[i][1], "format") == 0) {
        if (i < argc - 1)
          format = argv[++i];
      }
      else
        std::cerr << "Invalid option: " << argv[i] << std::endl;
    }
    else {
      if      (! filename) filename = argv[i];
      else if (! dx_str  ) dx_str   = argv[i];
      else if (! dy_str  ) dy_str   = argv[i];
      else if (! sx_str  ) sx_str   = argv[i];
      else if (! sy_str  ) sy_str   = argv[i];
    }
  }

  if (! filename || ! dx_str || ! dy_str) {
    std::cerr << "Usage: CImageUntile [-flip_dir] [-format <format>] "
                 "<ifile> <dx> <dy> [<sx>] [<sy>]" << std::endl;
    exit(1);
  }

  CFile *ifile = new CFile(filename);

  int dx = CStrUtil::toInteger(dx_str);
  int dy = CStrUtil::toInteger(dy_str);

  if (dx <= 0 || dy <= 0) return false;

  int sx = (sx_str ? CStrUtil::toInteger(sx_str) : 0);
  int sy = (sy_str ? CStrUtil::toInteger(sy_str) : 0);

  CImageFileSrc src(*ifile);

  CImagePtr image = CImageMgrInst->createImage(src);

  if (! image.isValid())
    exit(1);

  CFileType type = image->getType();

  int width  = image->getWidth ();
  int height = image->getHeight();

  if (! flip_dir) {
    for (int y = 0, iy = 1; y < height; y += dy + sy, ++iy) {
      for (int x = 0, ix = 1; x < width; x += dx + sx, ++ix) {
        CImagePtr image1 = image->subImage(x, y, dx, dy);

        std::string ind_str = indToString(format, ix, iy);

        std::string filename = ifile->getDir() + "/" + ifile->getBase() +
                               ind_str + "." + ifile->getSuffix();

        image1->write(filename, type);
      }
    }
  }
  else {
    for (int x = 0, ix = 1; x < width; x += dx + sx, ++ix) {
      for (int y = 0, iy = 1; y < height; y += dy + sy, ++iy) {
        CImagePtr image1 = image->subImage(x, y, dx, dy);

        std::string ind_str = indToString(format, iy, ix);

        std::string filename = ifile->getDir() + "/" + ifile->getBase() +
                               ind_str + "." + ifile->getSuffix();

        image1->write(filename, type);
      }
    }
  }

  delete ifile;

  exit(0);
}
开发者ID:colinw7,项目名称:CImageLib,代码行数:93,代码来源:CImageUntile.cpp


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