Results 1 to 6 of 6

Thread: Annoying RGB Problem!

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    33

    Angry

    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?

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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

  3. #3
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    The values of Red, Green and Blue need to be between 0 and 255 .

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    No, the RGB function cuts values over 255, therefore I only check the < 0 case.

  5. #5
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    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"
    Last edited by Mad Compie; Apr 22nd, 2001 at 06:08 AM.

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    33
    Thanks! It works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width