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


C++ wxImage::GetSubImage方法代码示例

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


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

示例1: SplitH

// static
ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor)
{
   ImageArray result;

   int width = src.GetWidth();
   int height = src.GetHeight();
   unsigned char *data = src.GetData();
   unsigned char *ptr = data;
   unsigned char magicRed = magicColor.Red();
   unsigned char magicGreen = magicColor.Green();
   unsigned char magicBlue = magicColor.Blue();
   bool cur, prev;
   int i, j, start;

   // Sanity check...
   if (width<=0 || height<=0 || data==NULL)
      return result;
   
   prev = false;
   start = 0;
   for(i=0; i<width+1; i++) {
      if (i < width) {
         unsigned char *ptr2 = ptr;
         cur = true;
         for(j=0; j<height && cur; j++) {
            if (!(ptr2[0] == magicRed &&
                  ptr2[1] == magicGreen &&
                  ptr2[2] == magicBlue))
               cur = false;
            ptr2 += 3 * width;
         }
      }
      else
         cur = !prev;
      
      if ((cur && !prev)) {
         wxRect subRect(start, 0, i-start, height);
         wxImage subImage;
         if (subRect.width > 0)
            subImage = src.GetSubImage(subRect);
         else
            subImage = wxImage(subRect.width, subRect.height);
         result.Add(subImage);
      }
      else if (!cur && prev) {
         start = i;
      }
      
      prev = cur;
      ptr += 3;
   }

   return result;
}
开发者ID:andreipaga,项目名称:audacity,代码行数:55,代码来源:ImageRoll.cpp

示例2: getSprite

wxBitmap gcThemeManager::getSprite(wxImage& img, const char* spriteId, const char* spriteName)
{
	SpriteRectI* rect = getSpriteRect(spriteId, spriteName);

	if (!rect || !img.IsOk())
		return wxBitmap();

	int w = rect->getW();
	int h = rect->getH();
	int x = rect->getX();
	int y = rect->getY();

	if (w < 0)
		w = img.GetWidth();

	if (h < 0)
		h =	img.GetHeight();

	if (w > img.GetWidth())
		w = img.GetWidth();

	if (h > img.GetHeight())
		h =	img.GetHeight();

	if (x < 0)
		x = 0;

	if (x > img.GetWidth() - w)
		x = 0;

	if (y < 0)
		y = 0;

	if (y > img.GetHeight() - h)
		y = 0;

	return wxBitmap( img.GetSubImage( wxRect(x,y,w,h) ) );
}
开发者ID:CSRedRat,项目名称:desura-app,代码行数:38,代码来源:gcThemeManager.cpp


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