vb,下标越界,事实错误'9',程序求rgb值

OptionExplicitDimimagepixels(2,1024,1024)AsIntegerDimxAsInteger,yAsInteger,filenameAs... Option Explicit
Dim imagepixels(2, 1024, 1024) As Integer
Dim x As Integer, y As Integer, filename As String
Dim pixel
Private Sub Loadin_Click()
Dim red As Long, green As Long, blue As Long
Dim i, j
filename = InputBox("输入文件名")
Picture1 = LoadPicture(filename)
x = Picture1.ScaleWidth: y = Picture1.ScaleHeight
For i = 0 To y - 1
For j = 0 To x - 1
pixel = Form1.Picture1.Point(j, i)
red = pixel Mod 256&
green = ((pixel And &HFF00) / 256&) Mod 256&
blue = (pixel / &H10000)
imagepixels(0, j, i) = red: imagepixels(1, j, i) = green: imagepixels(2, j, i) = blue ’调试时,下标越界处
Next j: Next i
End Sub

求 r g b值

输入路径后,取消或者载入图片,都是下标越界
求高手帮助,本人vb菜鸟……
展开
 我来答
xlzzc
2010-12-08 · TA获得超过7301个赞
知道大有可为答主
回答量:4205
采纳率:50%
帮助的人:1449万
展开全部
Option Explicit
Dim imagepixels() As Integer
Dim x As Integer, y As Integer, filename As String
Dim pixel
Private Sub Loadin_Click()
Dim red As Long, green As Long, blue As Long
Dim i, j
filename = InputBox("输入文件名")
Picture1 = LoadPicture(filename)
x = Picture1.ScaleWidth: y = Picture1.ScaleHeight
reDim imagepixels(2,x,y) As Integer//使用动态数组就好了
For i = 0 To y - 1
For j = 0 To x - 1
pixel = Form1.Picture1.Point(j, i)
red = pixel Mod 256&
green = ((pixel And &HFF00) / 256&) Mod 256&
blue = (pixel / &H10000)
imagepixels(0, j, i) = red: imagepixels(1, j, i) = green: imagepixels(2, j, i) = blue
Next j: Next i
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式