void FloodSeedFill(int x, int y, int old_color, int new_color)
{
if(GetPixelColor(x, y) == old_color)
{
SetPixelColor(x, y, new_color);
for(int i = 0; i < COUNT_OF(direction_8); i++)
{
FloodSeedFill(x + direction_8[i].x_offset,
y + direction_8[i].y_offset, old_color, new_color);
}
}
}
for循环实现了向8个联通方向的递归搜索,秘密就在direction_8的定义:
typedef struct tagDIRECTION
{
int x_offset;
int y_offset;
}DIRECTION;
DIRECTION direction_8[] = { {-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1} };
求红字部分的单位类型,是int char CString还是什么?
{
if(GetPixelColor(x, y) == old_color)
{
SetPixelColor(x, y, new_color);
for(int i = 0; i < COUNT_OF(direction_8); i++)
{
FloodSeedFill(x + direction_8[i].x_offset,
y + direction_8[i].y_offset, old_color, new_color);
}
}
}
for循环实现了向8个联通方向的递归搜索,秘密就在direction_8的定义:
typedef struct tagDIRECTION
{
int x_offset;
int y_offset;
}DIRECTION;
DIRECTION direction_8[] = { {-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1} };
求红字部分的单位类型,是int char CString还是什么?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货