本文整理汇总了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;
}
示例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) ) );
}