您的位置:程序门 -> vb -> 基础类



求教用extfloodfill填充区域颜色方法,谢谢!!!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


求教用extfloodfill填充区域颜色方法,谢谢!!!
发表于:2008-01-28 20:11:11 楼主
求教用extfloodfill填充区域颜色方法,谢谢!!!

如图中红色中间填满红色,绿色中间填满绿色:

http://www.vbgood.com/attachments/month_0801/uvg92m28zrtda==_rkmc5nhw71l9.jpg

画图:
dim   maxjl   as   long
dim   i,   kl   as   long
dim   mbrush           as   long
dim   crnewcolor   as   long
dim   startx   as   double,   starty   as   double
dim   startx1   as   double,   starty1   as   double,   starty2   as   double,   starty3   as   double

if   curjl   +   ts   >   ubound(hq)   then
        maxjl   =   ubound(hq)
else
        maxjl   =   curjl   +   ts
end   if
''''''''''''''''''''''''''''''''''''''
picbroad.drawwidth   =   1
picbroad.drawstyle   =   0
picbroad.line   (mousem3,   zxj1)-(picbroad.scalewidth,   mousem4),   vbblack,   bf
picbroad.line   (mousem3,   mousem4)-(picbroad.scalewidth,   mousem4),   vbred
picbroad.line   (mousem3,   zxj1)-(mousem3,   mousem4),   vbred
picbroad.drawwidth   =   1
picbroad.drawstyle   =   2
picbroad.line   (mousem3,   zxj1)-(picbroad.scalewidth,   zxj1),   vbred
picbroad.drawwidth   =   1
picbroad.drawstyle   =   0
'''''''''''''''''''''''''''''''
kl   =   0
for   i   =   curjl   to   maxjl   -   1
if   i   =   curjl   then
startx   =   (picbroad.scalewidth   *   0.98   -   mousem3)   /   ts   *   (i   -   curjl   +   1)   +   3   +   mousem3
startx1   =   (picbroad.scalewidth   *   0.98   -   mousem3)   /   ts   *   (i   -   curjl   +   1)   +   3   +   mousem3
starty   =   (hy   -   minlow)   *   ((zxj1   -   mousem4)   /   (maxhigh   -   minlow))   +   mousem4   -   1
starty1   =   (hy   -   minlow)   *   ((zxj1   -   mousem4)   /   (maxhigh   -   minlow))   +   mousem4   -   1
starty2   =   (hy   *   10   /   20   -   minlow)   *   ((zxj1   -   mousem4)   /   (maxhigh   -   minlow))   +   mousem4   -   1
starty3   =   (hy   *   10   /   20   -   minlow)   *   ((zxj1   -   mousem4)   /   (maxhigh   -   minlow))   +   mousem4   -   1
else
startx1   =   (picbroad.scalewidth   *   0.98   -   mousem3)   /   ts   *   (i   -   curjl   +   1)   +   3   +   mousem3
starty1   =   (hy   -   minlow)   *   ((zxj1   -   mousem4)   /   (maxhigh   -   minlow))   +   mousem4   -   1
starty3   =   (hy   *   10   /   20   -   minlow)   *   ((zxj1   -   mousem4)   /   (maxhigh   -   minlow))   +   mousem4   -   1
end   if

if   hy   >   hy   *   10   /   20   then

picbroad.line   (startx,   starty)-(startx1,   starty1),   vbred
picbroad.line   (startx,   starty2)-(startx1,   starty3),   vbred
'crnewcolor   =   vbred
'mbrush   =   createsolidbrush(crnewcolor)
'selectobject   picbroad.hdc,   mbrush
'extfloodfill   picbroad.hdc,   1,   1,   getpixel(picbroad.hdc,   startx   +   1,   starty   -   1),   1
end   if
if   hy   <   hy   *   10   /   20   then
picbroad.line   (startx,   starty)-(startx1,   starty1),   vbgreen
picbroad.line   (startx,   starty2)-(startx1,   starty3),   vbgreen
'crnewcolor   =   vbgreen
'mbrush   =   createsolidbrush(crnewcolor)
'   selectobject   picbroad.hdc,   mbrush
'picture1.line   (50,   100)-(300,   300),   vbgreen,   b
'extfloodfill   picbroad.hdc,   1,   1,   getpixel(picbroad.hdc,   startx   +   1,   starty   -   1),   1
end   if
startx   =   startx1
starty   =   starty1
starty2   =   starty3

next
发表于:2008-01-28 20:54:071楼 得分:0
hq数组在哪个地方?上面代码无法运行
发表于:2008-01-28 20:57:592楼 得分:0
在vb6.0中快速实现大面积不规则区域的填充     http://www.ccw.com.cn/htm/center/prog/02_8_5_3.asp
发表于:2008-01-29 10:52:033楼 得分:0
private   sub   picture1_mouseup(button   as   integer,   shift   as   integer,   x   as   single,   y   as   single)
picture1.scalemode   =   vbpixels   '单位必须是像素
picture1.fillstyle   =   0
picture1.fillcolor   =   vbred   '填充颜色
floodfill   picture1.hdc,   x,   y,   vbblack   '边界颜色是黑色
end   sub
发表于:2008-01-29 10:57:244楼 得分:0
补充,先声明:
private   declare   function   floodfill   lib   "gdi32"   (byval   hdc   as   long,   byval   x   as   long,   byval   y   as   long,   byval   crcolor   as   long)   as   long


快速检索

最新资讯
热门点击