1. Toan Nguyen
  2. PowerBuilder
  3. Thursday, 17 October 2024 16:40 PM UTC

Hello All,

Checking out the RGB() function in PB2017R3, I find that RGB(255,0,0) = #FF0000, value for Red color instead the color is actually Blue.

And, RGB(0,0,255) = #0000FF is supposed to be Blue color but it's actually Red.

Looks like the RGB() function is flip-flopping on Blue and Red colors.

Can someone confirm this finding in PowerBuilder 2017R3?

Thanks,

Toan Nguyen




Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 18 October 2024 13:11 PM UTC
  2. PowerBuilder
  3. # Permalink

So, where is the problem? You should not confuse hexadecimal with decimal. In hex representation, 0000FF doesn't mean 255, it means 0, 0, 255. And FF0000 doesn't mean 16711680. It means 255, 0, 0. This representation has nothing to do with the calculation rgb does in powerbuilder. If you want to relate it somehow, think of it like:

RGB(255, 0, 0) // -> FF, 00, 00
RGB(0, 0, 255) // -> 00, 00, FF

Don't be confused. In hex, no calculation is needed!

Andreas.

Comment
  1. Armeen Mazda @Appeon
  2. Friday, 18 October 2024 14:16 PM UTC
Thanks Andreas what good info and great catch! Easy to confuse these things.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 17 October 2024 17:03 PM UTC
  2. PowerBuilder
  3. # 1

Hi Toan;

 We have never had a reported issue on the RGB method. However, make sure that your receiving & working with its returned colour values using a "Long" data type.

https://docs.appeon.com/pb2022/powerscript_reference/rGB_func.html

Regards ... Chris 

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 18 October 2024 06:21 AM UTC
  2. PowerBuilder
  3. # 2

Hi.

No. I don't confirm. I never seen such an inconsistency related to rgb function. I did tested this to PB 2017 R3 Build 1951 and it works as expected. Take a look at Chris suggestion...

Andreas.

Comment
There are no comments made yet.
David Peace (Powersoft) Accepted Answer Pending Moderation
  1. Friday, 18 October 2024 10:20 AM UTC
  2. PowerBuilder
  3. # 3

I have tested it and get the follwing results:

RGB(255,0,0) = 255

RGB(0,0,255) = 16711680

Are you getting the same values returned?

Comment
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Friday, 18 October 2024 12:24 PM UTC
  2. PowerBuilder
  3. # 4

Hello All,

Thank you all for responses to my question.


Dave - Yes, I got RGB(0,0,255) = 16711680  and RGB(255,0,0) = 255.

I am confused about the color values returning from the RGB() function because seeing the RGB colors chart from https://www.justfreetools.com/en/rgb-color link: 

BLUE RGB code = 0*65536+0*256+255 = #0000FF ----> 255 (decimal)

RED RGB code = 255*65536+0*256+0 = #FF0000 ---> 16711680 (decimal)

GREEN RGB code = 0*65536+255*256+0 = #00FF00  ---> 65280 (decimal)

Thanks again everyone for your responses.

Regards,

Toan Nguyen

 

 

 

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 18 October 2024 13:22 PM UTC
  2. PowerBuilder
  3. # 5

By the way, it is also documented how powerbuilder calculates the color to a decimal number. It's 65536 * Blue+ 256 * Green+ Red and not 65536 * Red+ 256 * Green+ Blue.

Andreas.

Comment
There are no comments made yet.
Toan Nguyen Accepted Answer Pending Moderation
  1. Friday, 18 October 2024 14:09 PM UTC
  2. PowerBuilder
  3. # 6

Hi Andreas,

Thanks for the explanation!

Toan

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.