Author Topic: RGB func  (Read 2203 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
RGB func
« on: July 09, 2012, 06:17:50 AM »
I try to use RGB() function from old examples and i'm found that
something not work properly in mine GUI examples.
Old code is:
Code: [Select]
Function RGB(sys red, green, blue) as sys
Function = red + green*256 + blue*65536
End Function
i also try this to:
Code: [Select]
Function RGB(sys red,green,blue) as sys
green *=256: blue *=65536
Return red+green+blue             
End Function

And still i have wrong colors, it looks weird to me because in examples both
function works.
Then i found code for RGB() in DLib and finally this code work properly:  :)
Code: [Select]
Function RGB(sys red,green,blue) as sys
  sys color
  color = red
  color = color + green*256
  color = color + blue*65536
  Return color
End Function

Just for example i use RGB() function under message WM_PAINT
After window is created set DC:
Code: [Select]
'create window
win = SetWindow("Test AwinH",x,y,w,h,0,winstyle)
INT hDC=GetDC(win)

Then under WM_PAINT:
Code: [Select]
CASE WM_PAINT

'draw vertical lines--------
For x = 5 to 10
For y = 100 to 300
PSet(hdc, x, y, 242,242,222)
Next
Next
ReleaseDC(win,hdc)

I hope that will be useful... ;)



Charles Pegge

  • Guest
Re: RGB func
« Reply #1 on: July 09, 2012, 07:34:46 PM »
You can easily check the output of an rgb function like this:

Code: OxygenBasic
  1. function rgb(sys r,g,b) as sys
  2. return r+g*0x100+b*0x10000
  3. end function
  4.  
  5. print hex rgb(0xaa,0xbb,0xcc)
  6.  

Aurel

  • Guest
Re: RGB func
« Reply #2 on: July 09, 2012, 09:31:04 PM »
Thanks Charles...
Quote
What's the difference?
Big...on old way i get wrong colors mostly without blue component.
On this new way output is correct.
I will add exemple and you will show that i'm in right...
...if you don't belive :P