Jump to content

Pixel Color calculations


Recommended Posts

Hi all,

What I want to accomplish is the following:

Using the color of a pixel as reference, I want to update an array of colors so that if the reference pixel changes color, my array will change by the same amount.

Hope that made sense.

The following code does not work properly... please help.

$new_background = Hex(PixelGetColor(200,790), 6)
                        if $background_color <>  $current_background Then
                            For $i = 0 to $count Step 1
                                $color[$i] = $color[$i] -$background_color + $new_background
                            Next
                        $background_color = $new_background
Link to comment
Share on other sites

Isnt this better:

if Hex(PixelGetColor(200,790), 6) <> $background_color then 
$background_color=Hex(PixelGetColor(200,790), 6) 
$difference=$color[$i]-$background_color
$color[$i]=$color[$i]+$difference
endif

It is only an simple example code, but You have the Idea?

Helped? :P

Link to comment
Share on other sites

I've modified the code to the idea above, but it's not working.

I've used the debug feature.

New Background: 64636A, Old Background: 6F6E76

Old Color: 6E2610

New Color: 0

Old Color: 39221C

New Color: 0

Here is the code

$current_background = Hex(PixelGetColor(200,790), 6)
                        if $background_color <>  $current_background Then
                            _DebugOut ("New Background: " & $current_background  & ", Old Background: " & $background_color, 0)
                            For $i = 0 to $count Step 1
                                _DebugOut ("Old Color: " & $color[$i], 0)
                                $difference = $current_background - $background_color
                                $color[$i] = $color[$i] + $difference
                                _DebugOut ("New Color: " & $color[$i], 0)
                            Next
                        $background_color = $current_background

Please help~

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...