GDI+ 区域填充的有关问题
GDI+ 区域填充的问题
大家好,目前遇到一个难题:想要用GDI+来实现windows的颜料填充的功能,具体要求是这样的
1、在一张图中用鼠标画出条线 ,线是不规则的线 如:
2、用鼠标获取其中一个区域,并将其用填充图案填充,如:

这个过程我们应该如何处理呢,如何获取我们鼠标点击所在的闭合区域呢,现在没有一点思路,求大家帮帮忙。。。
------解决方案--------------------
CDC::ExtFloodFill
BOOL ExtFloodFill( int x, int y, COLORREF crColor, UINT nFillType );
Return Value
Nonzero if the function is successful; otherwise 0 if the filling could not be completed, if the given point has the boundary color specified by crColor (if FLOODFILLBORDER was requested), if the given point does not have the color specified by crColor (if FLOODFILLSURFACE was requested), or if the point is outside the clipping region.
Parameters
x
Specifies the logical x-coordinate of the point where filling begins.
y
Specifies the logical y-coordinate of the point where filling begins.
crColor
Specifies the color of the boundary or of the area to be filled. The interpretation of crColor depends on the value of nFillType.
nFillType
Specifies the type of flood fill to be performed. It must be either of the following values:
FLOODFILLBORDER The fill area is bounded by the color specified by crColor. This style is identical to the filling performed by FloodFill.
FLOODFILLSURFACE The fill area is defined by the color specified by crColor. Filling continues outward in all directions as long as the color is encountered. This style is useful for filling areas with multicolored boundaries.
Remarks
Fills an area of the display surface with the current brush. This member function offers more flexibility than FloodFill because you can specify a fill type in nFillType.
If nFillType is set to FLOODFILLBORDER, the area is assumed to be completely bounded by the color specified by crColor. The function begins at the point specified by x and y and fills in all directions to the color boundary.
If nFillType is set to FLOODFILLSURFACE, the function begins at the point specified by x and y and continues in all directions, filling all adjacent areas containing the color specified by crColor.
Only memory-device contexts and devices that support raster-display technology support ExtFloodFill. For more information, see the GetDeviceCaps member function.
大家好,目前遇到一个难题:想要用GDI+来实现windows的颜料填充的功能,具体要求是这样的
1、在一张图中用鼠标画出条线 ,线是不规则的线 如:
2、用鼠标获取其中一个区域,并将其用填充图案填充,如:
这个过程我们应该如何处理呢,如何获取我们鼠标点击所在的闭合区域呢,现在没有一点思路,求大家帮帮忙。。。
------解决方案--------------------
CDC::ExtFloodFill
BOOL ExtFloodFill( int x, int y, COLORREF crColor, UINT nFillType );
Return Value
Nonzero if the function is successful; otherwise 0 if the filling could not be completed, if the given point has the boundary color specified by crColor (if FLOODFILLBORDER was requested), if the given point does not have the color specified by crColor (if FLOODFILLSURFACE was requested), or if the point is outside the clipping region.
Parameters
x
Specifies the logical x-coordinate of the point where filling begins.
y
Specifies the logical y-coordinate of the point where filling begins.
crColor
Specifies the color of the boundary or of the area to be filled. The interpretation of crColor depends on the value of nFillType.
nFillType
Specifies the type of flood fill to be performed. It must be either of the following values:
FLOODFILLBORDER The fill area is bounded by the color specified by crColor. This style is identical to the filling performed by FloodFill.
FLOODFILLSURFACE The fill area is defined by the color specified by crColor. Filling continues outward in all directions as long as the color is encountered. This style is useful for filling areas with multicolored boundaries.
Remarks
Fills an area of the display surface with the current brush. This member function offers more flexibility than FloodFill because you can specify a fill type in nFillType.
If nFillType is set to FLOODFILLBORDER, the area is assumed to be completely bounded by the color specified by crColor. The function begins at the point specified by x and y and fills in all directions to the color boundary.
If nFillType is set to FLOODFILLSURFACE, the function begins at the point specified by x and y and continues in all directions, filling all adjacent areas containing the color specified by crColor.
Only memory-device contexts and devices that support raster-display technology support ExtFloodFill. For more information, see the GetDeviceCaps member function.