Read / WritePreferenceRGBColor
Posted: Sat Jan 14, 2012 5:31 am
Hello everyone,
Okay, here is another code that does not deserve a Nobel Prize but I hope it will be useful to someone.
Best regards
Guimauve
Okay, here is another code that does not deserve a Nobel Prize but I hope it will be useful to someone.
Best regards
Guimauve
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Read / WritePreferenceRGBColor
; File Name : Read-WritePreferenceRGBColor.pb
; File version: 1.0.0
; Programmation : OK
; Programmed by : Guimauve
; Date : 08-05-2011
; Last Update : 13-01-2012
; PureBasic code : 4.60 - 4.61
; Plateform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Procedure WritePreferenceRGBColor(KeyWord.s, Color.l)
WritePreferenceString(KeyWord, "RGB(" + RSet(Str(Red(Color)), 3, "0") + ", " + RSet(Str(Green(Color)), 3, "0") + ", " + RSet(Str(Blue(Color)), 3, "0") + ")")
EndProcedure
Procedure ReadPreferenceRGBColor(KeyWord.s, Color.l)
Formatted_Color.s = ReadPreferenceString(KeyWord, "RGB(" + RSet(Str(Red(Color)), 3, "0") + ", " + RSet(Str(Green(Color)), 3, "0") + ", " + RSet(Str(Blue(Color)), 3, "0") + ")")
If Formatted_Color = ""
ColorValue.l = Color
Else
Values.s = StringField(StringField(Formatted_Color, 2, "("), 1, ")")
Red.a = Val(StringField(Values, 1, ","))
Green.a = Val(StringField(Values, 2, ","))
Blue.a = Val(StringField(Values, 3, ","))
ColorValue.l = (Blue) << 16 + (Green) << 8 + (Red)
EndIf
ProcedureReturn ColorValue
EndProcedure
Procedure WritePreferenceRGBAColor(KeyWord.s, Color.l)
WritePreferenceString(KeyWord, "RGBA(" + RSet(Str(Red(Color)), 3, "0") + ", " + RSet(Str(Green(Color)), 3, "0") + ", " + RSet(Str(Blue(Color)), 3, "0") + ", " + RSet(Str(Alpha(Color)), 3, "0") + ")")
EndProcedure
Procedure ReadPreferenceRGBAColor(KeyWord.s, Color.l)
Formatted_Color.s = ReadPreferenceString(KeyWord, "RGBA(" + RSet(Str(Red(Color)), 3, "0") + ", " + RSet(Str(Green(Color)), 3, "0") + ", " + RSet(Str(Blue(Color)), 3, "0") + ", " + RSet(Str(Alpha(Color)), 3, "0") + ")")
If Formatted_Color = ""
ColorValue.l = Color
Else
Values.s = StringField(StringField(Formatted_Color, 2, "("), 1, ")")
Red.a = Val(StringField(Values, 1, ","))
Green.a = Val(StringField(Values, 2, ","))
Blue.a = Val(StringField(Values, 3, ","))
Alpha.a = Val(StringField(Values, 4, ","))
ColorValue = (Alpha) << 24 + (Blue) << 16 + (Green) << 8 + (Red)
EndIf
ProcedureReturn ColorValue
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<