The Rgb24toRgb15 function will covert a packed 24bit RGB colour value to a 15bit (555) RGB colour value.
FACTS:
* The input colour must be in the form. $--RRGGBB
* The function will convert the colour to a 16bit (rrrrrgggggbbbbb 555) format.
* Converting between 24bit and 15Bit means some colour information is lost.
Mini Tutorial:
Show some examples
; Convert some 24bit RGB colour to 15 and 16 bit format Show_Converted_16bit_Colour(RGB(255,255,255)) Show_Converted_15bit_Colour(RGB(255,255,255)) Show_Converted_16bit_Colour(RGB(255,0,0)) Show_Converted_15bit_Colour(RGB(255,0,0)) Show_Converted_16bit_Colour(RGB(0,255,0)) Show_Converted_15bit_Colour(RGB(0,255,0)) Show_Converted_16bit_Colour(RGB(0,0,255)) Show_Converted_15bit_Colour(RGB(0,0,255)) Sync WaitKey Function Show_Converted_16bit_Colour(ThisRGB) Print "16Bit" ; Print the Colour Value in Hex$ Print Hex$(ThisRgb) ; Convert the 24bit colour to a 16bit equivalent ; Note: some of the lower bits of the colour will ; be lose during the conversion !! NewCol_16Bit = RGB24ToRGB16(ThisRgb) ; Print the Colour Value in Hex$ Print Hex$(NewCol_16Bit) ; Now Convert the 16 bit colour back to 24 bit NewCol_24Bit = RGB16ToRGB24( NewCol_16Bit) Print Hex$(NewCol_24Bit) Print "" EndFunction Function Show_Converted_15bit_Colour(ThisRGB) Print "15Bit" ; Print the Colour Value in Hex$ Print Hex$(ThisRgb) ; Convert the 24bit colour to a 15bit equivalent ; Note: some of the lower bits of the colour will ; be lose during the conversion !! NewCol_15Bit = RGB24ToRGB15(ThisRgb) ; Print the Colour Value in Hex$ Print Hex$(NewCol_15Bit) ; Now Convert the 16 bit colour back to 24 bit NewCol_24Bit = RGB15ToRGB24( NewCol_15Bit) Print Hex$(NewCol_24Bit) Print "" EndFunction |
This example would output. 16Bit $00FFFFFF $0000FFFF $00F8FCF8 15Bit $00FFFFFF $00007FFF $00F8F8F8 16Bit $00FF0000 $0000F800 $00F80000 15Bit $00FF0000 $00007C00 $00F80000 16Bit $0000FF00 $000007E0 $0000FC00 15Bit $0000FF00 $000003E0 $0000F800 16Bit $000000FF $0000001F $000000F8 15Bit $000000FF $0000001F $000000F8 |
|