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菜鸟…… 展开
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菜鸟…… 展开
1个回答
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询