| 发表于:2007-01-02 11:01:23 楼主 |
请问下面程序想实现在左边图片框中鼠标单击任一点蓝色区域实现在右边图片框把与刚才点选的那一点相连续的所有点变成绿色,为什么会出现“实时错误28,堆栈空间溢出”的错误呢?谢谢各位了。代码如下: version 5.00 begin vb.form form1 caption = "form1 " clientheight = 6285 clientleft = 60 clienttop = 450 clientwidth = 9000 linktopic = "form1 " scaleheight = 6285 scalewidth = 9000 startupposition = 3 '窗口缺省 windowstate = 2 'maximized begin vb.picturebox pic2 autoredraw = -1 'true autosize = -1 'true height = 2295 left = 5640 scaleheight = 149 scalemode = 3 'pixel scalewidth = 173 tabindex = 1 top = 120 width = 2655 end begin vb.picturebox pic1 autoredraw = -1 'true autosize = -1 'true height = 4830 left = 120 picture = "form1.frx ":0000 scaleheight = 318 scalemode = 3 'pixel scalewidth = 356 tabindex = 0 top = 120 width = 5400 end end attribute vb_name = "form1 " attribute vb_globalnamespace = false attribute vb_creatable = false attribute vb_predeclaredid = true attribute vb_exposed = false private type bitmap '14 bytes bmtype as long bmwidth as long bmheight as long bmwidthbytes as long bmplanes as integer bmbitspixel as integer bmbits as long end type private declare function getobject lib "gdi32 " alias "getobjecta " (byval hobject as long, byval ncount as long, lpobject as any) as long private declare function getbitmapbits lib "gdi32 " (byval hbitmap as long, byval dwcount as long, lpbits as any) as long private declare function setbitmapbits lib "gdi32 " (byval hbitmap as long, byval dwcount as long, lpbits as any) as long dim picbits() as byte dim picinfod as bitmap '调入处理后图像所用的信息 dim bytesperpixel as integer 'get bitmap info private function getbi(pic as picturebox, picbits() as byte) dim i as long with pic getobject .image, len(picinfod), picinfod bytesperpixel = picinfod.bmbitspixel \ 8 redim picbits(1 to picinfod.bmwidth * picinfod.bmheight * bytesperpixel) getbitmapbits .image, ubound(picbits), picbits(1) end with end function '在图像上反选与点击的点连续的图像 private function ssmo(x as single, y as single, c as integer) 'on error resume next if picbits((y * picinfod.bmwidth + x) * bytesperpixel + c) = 255 then picbits((y * picinfod.bmwidth + x) * bytesperpixel + c) = 0 picbits((y * picinfod.bmwidth + x) * bytesperpixel + 3 - c) = 255 doevents if picbits(((y - 1) * picinfod.bmwidth + x - 1) * bytesperpixel + c) = 255 then ssmo x - 1, y - 1, c end if if picbits(((y - 1) * picinfod.bmwidth + x) * bytesperpixel + c) = 255 then ssmo x, y - 1, c end if if picbits(((y - 1) * picinfod.bmwidth + x + 1) * bytesperpixel + c) = 255 then ssmo x + 1, y - 1, c end if if picbits((y * picinfod.bmwidth + x - 1) * bytesperpixel + c) = 255 then ssmo x - 1, y, c end if if picbits((y * picinfod.bmwidth + x + 1) * bytesperpixel + c) = 255 then ssmo x + 1, y, c end if if picbits(((y + 1) * picinfod.bmwidth + x - 1) * bytesperpixel + c) = 255 then ssmo x - 1, y + 1, c end if if picbits(((y + 1) * picinfod.bmwidth + x) * bytesperpixel + c) = 255 then ssmo x, y + 1, c end if if picbits(((y + 1) * picinfod.bmwidth + x + 1) * bytesperpixel + c) = 255 then ssmo x + 1, y + 1, c end if end if exit function end function private sub form_load() pic2.width = pic1.width pic2.height = pic1.height getbi pic1, picbits() end sub private sub pic1_mousedown(button as integer, shift as integer, x as single, y as single) ssmo x, y, 1 setbitmapbits pic2.image, ubound(picbits), picbits(1) end sub |
|
|
|
|