The following piece of code blurs a picture box but the compiler wont let me use a variable for the picture width or height, it only wants a constant. Can anyone tell me Why i cant use a variable (intUpperBoundY) in the DIM PIXELS line (1st line of code)? This value may change depending on the size of the picture I am blurring and so cant use a constant. Thanks for any pointers
VB Code:
Private Sub Blur(intUpperBoundX, intUpperBoundY) Dim Pixels(1 To intUpperBoundX, 1 To intUpperBoundY) As Long Dim x, y As Integer Dim bytRed, bytGreen, bytBlue As Byte For x = 1 To intUpperBoundX For y = 1 To intUpperBoundY Pixels(x, y) = Picture1.Point(x, y) Next y Next x For x = 1 To intUpperBoundX - 1 For y = 1 To intUpperBoundY bytRed = Abs((Pixels(x + 1, y) And &HFF) + (Pixels(x, y) And &HFF)) / 2 bytGreen = Abs(((Pixels(x + 1, y) And &HFF00) / &H100) Mod &H100 + ((Pixels(x, y) And &HFF00) / &H100) Mod &H100) / 2 bytBlue = Abs(((Pixels(x + 1, y) And &HFF0000) / &H10000) Mod &H100 + ((Pixels(x, y) And &HFF0000) / &H10000) Mod &H100) / 2 Pixels(x, y) = RGB(bytRed, bytGreen, bytBlue) Next y Next x For x = 1 To intUpperBoundX For y = 1 To intUpperBoundY Picture2.PSet (x, y), Pixels(x, y) Next y Next x End Sub
Is it possible to create a constant on the fly based on a variable?




Reply With Quote