Hi,
how can i convert a "ff00ff"-String in this 3 numbers (red green blue) for rgb()?
Thanks for helping me!
"ff00ff" to rgb(255, 0, 255) for example
Re: "ff00ff" to rgb(255, 0, 255) for example
Hi,
you can use
Or
I hope that's what you mean.
Bernd
you can use
Code: Select all
RGB($FF, $00, $FF)
Code: Select all
val("$" + "FF00FF")
Bernd
Re: "ff00ff" to rgb(255, 0, 255) for example
Thanks, the second example is the right thing!
- VB6_to_PBx
- Enthusiast
- Posts: 627
- Joined: Mon May 09, 2011 9:36 am
Re: "ff00ff" to rgb(255, 0, 255) for example
would this also be OK to use ??
Code: Select all
Debug Val(Str(RGB($FF, $00, $FF)))
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
Re: "ff00ff" to rgb(255, 0, 255) for example
Simply test it
This shows also that the colour in PB is expected as BGR an dnot RGB.
Bernd

Code: Select all
Debug Hex(Val(Str(RGB($FF, $00, $FE))))
Bernd
- VB6_to_PBx
- Enthusiast
- Posts: 627
- Joined: Mon May 09, 2011 9:36 am
Re: "ff00ff" to rgb(255, 0, 255) for example
Code: Select all
Debug Val(Str(RGB($00, $00, $FF)))
16711680
and
Code: Select all
Debug Val(Str(RGB($FF, $00, $FF)))
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
Re: "ff00ff" to rgb(255, 0, 255) for example
The color value is just an integer number. Val() converts it to a string in Decimal format, but you are expecting it in Hex() format.
Example:
Example:
Code: Select all
Structure RGBA
R.a
G.a
B.a
A.a
EndStructure
Procedure ReverseRGB(Color)
*Temp.RGBA = @Color
Swap *Temp\R, *Temp\B
ProcedureReturn PeekL(*Temp)
EndProcedure
a = RGB(255, 128, 64)
b = RGB($FF, $80, $40)
c = $4080FF
Debug "Hex (BBGGRR):"
Debug "$" + Hex(a)
Debug "$" + Hex(b)
Debug "$" + Hex(c)
Debug ""
Debug "Hex (RRGGBB, CSS-style):"
Debug "#" + Hex(ReverseRGB(a))
Debug "#" + Hex(ReverseRGB(b))
Debug "#" + Hex(ReverseRGB(c))
Debug ""
Debug "Decimal:"
Debug Str(a)
Debug Str(b)
Debug Str(c)