-
I am using the RGB function in compositing. It is like this:
Code:
res = RGB((red1 + red2) / 2, (green1 + green2) / 2, (blue1 + blue2) / 2)
All the variables being used are integers. When I run the app, it says "Invalid procedure or argument". What can I do?
-
On of these values seems to be out of range (smaller 0), check this before calling the function:
Code:
Sub CalcColor()
Dim Red1 As Long
Dim Red2 As Long
Dim Green1 As Long
Dim Green2 As Long
Dim Blue1 As Long
Dim Blue2 As Long
Dim R As Long
Dim G As Long
Dim B As Long
Dim Res As Long
R = (Red1 + Red2) / 2
G = (Green1 + Green2) / 2
B = (Blue2 + Red2) / 2
If R < 0 Then: R = 0
If G < 0 Then: G = 0
If B < 0 Then: B = 0
Res = RGB(R, G, B)
End Sub
-
The values of Red, Green and Blue need to be between 0 and 255 .
-
No, the RGB function cuts values over 255, therefore I only check the < 0 case.
-
Yes, but I meant that a RGB value is a Long containing 3 bytes, each from 0 to 255.
VB does the check if greather than 255.
If a RGB byte is >255 and <32768 then this byte will be 255.
If a RGB byte is >32767 then "Overflow" is generated.
If a RGB byte is <0 then "Invalid prodcedure call/argument" is generated"
-