RGB and whatdotcolor
Author |
Message |
Insectoid
|
Posted: Tue Nov 11, 2008 2:21 pm Post subject: RGB and whatdotcolor |
|
|
Well, I have been working on a program that takes a picture, gets the information for each pixel (x, y, color) and saves it to a text file before displaying the picture in an interesting way to the screen, using the numbers in the text file. Unfortunately, I am restricted to the 256-bit limits of whatdotcolor (used to get the color information for the pixel). So, is there a way to get the color information in RGB format using whatdotcolor, or even directly obtain the info from the jpeg image?
Description: |
|
Download |
Filename: |
Drawing Programs.zip |
Filesize: |
39.63 KB |
Downloaded: |
118 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Tue Nov 11, 2008 3:37 pm Post subject: Re: RGB and whatdotcolor |
|
|
yes, you can use the RGB.GetColour command to get RGB values based on the Turing Colour number.
Turing: |
RGB.GetColour(colournum,real_variable,real_variable2,real_variable3 )
|
will return the RGB values into the three real variables you give it.
|
|
|
|
|
|
The_Bean
|
Posted: Tue Nov 11, 2008 4:13 pm Post subject: Re: RGB and whatdotcolor |
|
|
The problem with using RGB.GetColour is that you first need to know what the colour is you want to get the information for, so you have to use View.WhatDotColour, which returns a colour inside the 256 range, and your back to where you start.
To get a better range of colours you need to use RGB.SetColour and RGB.AddColour
You can only add up to 1024 or something colours but that still gives a pretty good range.
Turing: |
View.Set ("graphics:1000,216,nobuttonbar,offscreenonly")
var nothing : int
%Sets all the colours
for r : 0 .. 9
for g : 0 .. 9
for b : 0 .. 9
if r * 100 + g * 10 + b < 256 then % if the colour is within the the current 256 range
RGB.SetColour (r * 100 + g * 10 + b, r / 9, g / 9, b / 9) %changes the colours under 256
else
nothing := RGB.AddColour (r / 9, g / 9, b / 9) % adds new colours ontop of the 256
end if
end for
end for
end for
%draws the lines
for r : 0 .. 9
for g : 0 .. 9
for b : 0 .. 9
Draw.Line (r * 100 + g * 10 + b, 0, r * 100 + g * 10 + b, 199, r * 100 + g * 10 + b )
end for
end for
end for
var xm, ym, bm : int
var r, g, b : real
Text.Colour (999)
Text.ColourBack (0)
loop
Mouse.Where (xm, ym, bm )
RGB.GetColour (View.WhatDotColour (xm, ym ), r, g, b )
locate (1, 1)
put "Colour ", View.WhatDotColour (xm, ym ) : 3, " is made of: ", r : 3 : 2, " red, ", g : 3 : 2, " green, ", b : 3 : 2, " blue."
View.Update
exit when hasch
end loop
|
|
|
|
|
|
|
Insectoid
|
Posted: Tue Nov 11, 2008 4:32 pm Post subject: RE:RGB and whatdotcolor |
|
|
Wow...that looks very comlicated and makes little sense...Does it add colors to the 256-bit range? And will it capture the RGB exactly?
|
|
|
|
|
|
The_Bean
|
Posted: Tue Nov 11, 2008 4:44 pm Post subject: Re: RGB and whatdotcolor |
|
|
It won't get the RGB exactly, but it comes a lot closer than what turing already has. The main thing you want is
Turing: |
%Sets all the colours
for r : 0 .. 9
for g : 0 .. 9
for b : 0 .. 9
if r * 100 + g * 10 + b < 256 then % if the colour is within the the current 256 range
RGB.SetColour (r * 100 + g * 10 + b, r / 9, g / 9, b / 9) %changes the colours under 256
else
nothing := RGB.AddColour (r / 9, g / 9, b / 9) % adds new colours ontop of the 256
end if
end for
end for
end for
%0..9 for each colour so you get an even representation for each colour
%We switch from RGB.Set to RGB.Add because if we try and set a colour over 256 turing gives an error because
%that colour doesn't currently exist. So we then add colours.
%We can't get any better definision out of turing because it has a max of 1024 colours
%10*10*10 is 1000 so were really close with this already
|
Description: |
|
Filesize: |
137.36 KB |
Viewed: |
140 Time(s) |
|
|
|
|
|
|
|
Insectoid
|
Posted: Tue Nov 11, 2008 4:53 pm Post subject: RE:RGB and whatdotcolor |
|
|
Hmm...Perhaps I'll just give this a go in Java. Turing is apparently to limited for this kind of activity.
|
|
|
|
|
|
SNIPERDUDE
|
Posted: Wed Nov 12, 2008 8:13 pm Post subject: RE:RGB and whatdotcolor |
|
|
It is best if you make the RGB retrieving programme in another language, I used VB for mine.
|
|
|
|
|
|
Insectoid
|
Posted: Wed Nov 12, 2008 8:14 pm Post subject: RE:RGB and whatdotcolor |
|
|
If only I could get the Robot class to work in Java...
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|