首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

PictureBox取点有关问题

2012-01-30 
PictureBox取点问题有一个Picture1,尺寸大小为16x128,则可以用下面的代码进行取点:dimx,y,iaslongfory0to

PictureBox取点问题
有一个Picture1,尺寸大小为16x128,则可以用下面的代码进行取点:
dim   x,y,i   as   long
for   y   =   0   to   15
        for   x   =   0   to   127
              ardata(i)   =   picture1.point(x,y)
              i   =   i   +   1
        next
next
如果有一个按钮,每点击一次,Picture1的Height增加16,假定每16点高为一个Page,即每点一次按钮Page加1,可以得到代码:
dim   x,y,i,row   as   long
row   =   16   *   page
for   y   =   (0   to   row   -   1)
        for   x   =   0   to   127  
                ardata(i)   =   picture1.point(x,y)
                i   =   i   +   1
        next
next

但是如果是一个Picture1()数组呢?要怎么取点?
像上面的如果Picture1.Height   =   32,即为2个Page
如果以数组来体现就是Picture1(0)、Picture1(1),
Picture1(0)显示Picture1中0-15高度区域的图片,Picture1(1)显示Picture1中16-31高度区域的图片,Picture1()数组是通过点击按钮动态添加的,如何取点法?请高手看看,谢谢!

[解决办法]
Dim x As Long, y As Long, i As Long, row As Long
Dim pageIndex As Integer
For pageIndex = 0 To 3
row = 16 * Page
For y = 0 To (row - 1)
For x = 0 To 127
ardata(i) = picture1(pageIndex).Point(x, y)
i = i + 1
Next
Next
'加取到一页的点后所需操作代码
redim ardata() '还是不知道你这个数组大小怎么定义的...?
i = 0
Next

思路应该这样的...

热点排行